aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-10-30 19:47:24 +0000
committerChristian Grothoff <christian@grothoff.org>2013-10-30 19:47:24 +0000
commit89ebafb9a1264e7a336cc348ce2c2426898da3a4 (patch)
tree93a7ec7c87fa49ef3d1f66047537ac49b9161b23
parent1a5f5d2d2a20fcf49ee203db2d627ff52165aaa2 (diff)
downloadgnunet-gtk-89ebafb9a1264e7a336cc348ce2c2426898da3a4.tar.gz
gnunet-gtk-89ebafb9a1264e7a336cc348ce2c2426898da3a4.zip
-finishing implementation of pluggable dialogs (#3081)
-rw-r--r--contrib/gnunet_namestore_edit_a.glade1
-rw-r--r--contrib/gnunet_namestore_edit_aaaa.glade1
-rw-r--r--contrib/gnunet_namestore_edit_cname.glade1
-rw-r--r--contrib/gnunet_namestore_edit_gns2dns.glade1
-rw-r--r--contrib/gnunet_namestore_edit_leho.glade1
-rw-r--r--contrib/gnunet_namestore_edit_mx.glade1
-rw-r--r--contrib/gnunet_namestore_edit_phone.glade1
-rw-r--r--contrib/gnunet_namestore_edit_pkey.glade1
-rw-r--r--contrib/gnunet_namestore_edit_ptr.glade1
-rw-r--r--contrib/gnunet_namestore_edit_soa.glade1
-rw-r--r--contrib/gnunet_namestore_edit_srv.glade1
-rw-r--r--contrib/gnunet_namestore_edit_txt.glade1
-rw-r--r--contrib/gnunet_namestore_edit_vpn.glade1
-rw-r--r--src/include/gnunet_gtk.h20
-rw-r--r--src/include/gnunet_gtk_namestore_plugin.h116
-rw-r--r--src/lib/glade.c20
-rw-r--r--src/namestore/Makefile.am3
-rw-r--r--src/namestore/gnunet-namestore-gtk.c587
-rw-r--r--src/namestore/gnunet-namestore-gtk_edit.c1965
-rw-r--r--src/namestore/gnunet-namestore-gtk_edit.h292
-rw-r--r--src/namestore/plugin_gtk_namestore_a.c14
-rw-r--r--src/namestore/plugin_gtk_namestore_aaaa.c14
-rw-r--r--src/namestore/plugin_gtk_namestore_cname.c14
-rw-r--r--src/namestore/plugin_gtk_namestore_gns2dns.c14
-rw-r--r--src/namestore/plugin_gtk_namestore_leho.c16
-rw-r--r--src/namestore/plugin_gtk_namestore_mx.c14
-rw-r--r--src/namestore/plugin_gtk_namestore_phone.c16
-rw-r--r--src/namestore/plugin_gtk_namestore_pkey.c14
-rw-r--r--src/namestore/plugin_gtk_namestore_ptr.c14
-rw-r--r--src/namestore/plugin_gtk_namestore_soa.c22
-rw-r--r--src/namestore/plugin_gtk_namestore_srv.c6
-rw-r--r--src/namestore/plugin_gtk_namestore_template.c14
-rw-r--r--src/namestore/plugin_gtk_namestore_txt.c29
-rw-r--r--src/namestore/plugin_gtk_namestore_vpn.c14
34 files changed, 832 insertions, 2399 deletions
diff --git a/contrib/gnunet_namestore_edit_a.glade b/contrib/gnunet_namestore_edit_a.glade
index d9afbe92..a02404cd 100644
--- a/contrib/gnunet_namestore_edit_a.glade
+++ b/contrib/gnunet_namestore_edit_a.glade
@@ -41,7 +41,6 @@
41 <property name="window_position">center-on-parent</property> 41 <property name="window_position">center-on-parent</property>
42 <property name="destroy_with_parent">True</property> 42 <property name="destroy_with_parent">True</property>
43 <property name="type_hint">dialog</property> 43 <property name="type_hint">dialog</property>
44 <signal name="response" handler="GNS_edit_a_dialog_response_cb" swapped="no"/>
45 <child internal-child="vbox"> 44 <child internal-child="vbox">
46 <object class="GtkVBox" id="edit_dialog_vbox"> 45 <object class="GtkVBox" id="edit_dialog_vbox">
47 <property name="visible">True</property> 46 <property name="visible">True</property>
diff --git a/contrib/gnunet_namestore_edit_aaaa.glade b/contrib/gnunet_namestore_edit_aaaa.glade
index b2fb0281..451acf82 100644
--- a/contrib/gnunet_namestore_edit_aaaa.glade
+++ b/contrib/gnunet_namestore_edit_aaaa.glade
@@ -24,7 +24,6 @@
24 <property name="window_position">center-on-parent</property> 24 <property name="window_position">center-on-parent</property>
25 <property name="destroy_with_parent">True</property> 25 <property name="destroy_with_parent">True</property>
26 <property name="type_hint">dialog</property> 26 <property name="type_hint">dialog</property>
27 <signal name="response" handler="GNS_edit_aaaa_dialog_response_cb" swapped="no"/>
28 <child internal-child="vbox"> 27 <child internal-child="vbox">
29 <object class="GtkVBox" id="edit_dialog_vbox"> 28 <object class="GtkVBox" id="edit_dialog_vbox">
30 <property name="visible">True</property> 29 <property name="visible">True</property>
diff --git a/contrib/gnunet_namestore_edit_cname.glade b/contrib/gnunet_namestore_edit_cname.glade
index ab3e71f0..10711639 100644
--- a/contrib/gnunet_namestore_edit_cname.glade
+++ b/contrib/gnunet_namestore_edit_cname.glade
@@ -24,7 +24,6 @@
24 <property name="window_position">center-on-parent</property> 24 <property name="window_position">center-on-parent</property>
25 <property name="destroy_with_parent">True</property> 25 <property name="destroy_with_parent">True</property>
26 <property name="type_hint">dialog</property> 26 <property name="type_hint">dialog</property>
27 <signal name="response" handler="GNS_edit_cname_dialog_response_cb" swapped="no"/>
28 <child internal-child="vbox"> 27 <child internal-child="vbox">
29 <object class="GtkVBox" id="edit_dialog_vbox"> 28 <object class="GtkVBox" id="edit_dialog_vbox">
30 <property name="visible">True</property> 29 <property name="visible">True</property>
diff --git a/contrib/gnunet_namestore_edit_gns2dns.glade b/contrib/gnunet_namestore_edit_gns2dns.glade
index 35e36145..9cc58132 100644
--- a/contrib/gnunet_namestore_edit_gns2dns.glade
+++ b/contrib/gnunet_namestore_edit_gns2dns.glade
@@ -41,7 +41,6 @@
41 <property name="window_position">center-on-parent</property> 41 <property name="window_position">center-on-parent</property>
42 <property name="destroy_with_parent">True</property> 42 <property name="destroy_with_parent">True</property>
43 <property name="type_hint">dialog</property> 43 <property name="type_hint">dialog</property>
44 <signal name="response" handler="GNS_edit_gns2dns_dialog_response_cb" swapped="no"/>
45 <child internal-child="vbox"> 44 <child internal-child="vbox">
46 <object class="GtkVBox" id="edit_dialog_vbox"> 45 <object class="GtkVBox" id="edit_dialog_vbox">
47 <property name="visible">True</property> 46 <property name="visible">True</property>
diff --git a/contrib/gnunet_namestore_edit_leho.glade b/contrib/gnunet_namestore_edit_leho.glade
index 800a63fb..664e06bb 100644
--- a/contrib/gnunet_namestore_edit_leho.glade
+++ b/contrib/gnunet_namestore_edit_leho.glade
@@ -41,7 +41,6 @@
41 <property name="window_position">center-on-parent</property> 41 <property name="window_position">center-on-parent</property>
42 <property name="destroy_with_parent">True</property> 42 <property name="destroy_with_parent">True</property>
43 <property name="type_hint">dialog</property> 43 <property name="type_hint">dialog</property>
44 <signal name="response" handler="GNS_edit_leho_dialog_response_cb" swapped="no"/>
45 <child internal-child="vbox"> 44 <child internal-child="vbox">
46 <object class="GtkVBox" id="edit_dialog_vbox"> 45 <object class="GtkVBox" id="edit_dialog_vbox">
47 <property name="visible">True</property> 46 <property name="visible">True</property>
diff --git a/contrib/gnunet_namestore_edit_mx.glade b/contrib/gnunet_namestore_edit_mx.glade
index 833a9809..ec5fa98f 100644
--- a/contrib/gnunet_namestore_edit_mx.glade
+++ b/contrib/gnunet_namestore_edit_mx.glade
@@ -46,7 +46,6 @@
46 <property name="window_position">center-on-parent</property> 46 <property name="window_position">center-on-parent</property>
47 <property name="destroy_with_parent">True</property> 47 <property name="destroy_with_parent">True</property>
48 <property name="type_hint">dialog</property> 48 <property name="type_hint">dialog</property>
49 <signal name="response" handler="GNS_edit_mx_dialog_response_cb" swapped="no"/>
50 <child internal-child="vbox"> 49 <child internal-child="vbox">
51 <object class="GtkVBox" id="edit_dialog_vbox"> 50 <object class="GtkVBox" id="edit_dialog_vbox">
52 <property name="visible">True</property> 51 <property name="visible">True</property>
diff --git a/contrib/gnunet_namestore_edit_phone.glade b/contrib/gnunet_namestore_edit_phone.glade
index 63d202f1..1c32403b 100644
--- a/contrib/gnunet_namestore_edit_phone.glade
+++ b/contrib/gnunet_namestore_edit_phone.glade
@@ -47,7 +47,6 @@
47 <property name="window_position">center-on-parent</property> 47 <property name="window_position">center-on-parent</property>
48 <property name="destroy_with_parent">True</property> 48 <property name="destroy_with_parent">True</property>
49 <property name="type_hint">dialog</property> 49 <property name="type_hint">dialog</property>
50 <signal name="response" handler="GNS_edit_phone_dialog_response_cb" swapped="no"/>
51 <child internal-child="vbox"> 50 <child internal-child="vbox">
52 <object class="GtkVBox" id="edit_dialog_vbox"> 51 <object class="GtkVBox" id="edit_dialog_vbox">
53 <property name="visible">True</property> 52 <property name="visible">True</property>
diff --git a/contrib/gnunet_namestore_edit_pkey.glade b/contrib/gnunet_namestore_edit_pkey.glade
index e2d55c18..ebbcb8cc 100644
--- a/contrib/gnunet_namestore_edit_pkey.glade
+++ b/contrib/gnunet_namestore_edit_pkey.glade
@@ -41,7 +41,6 @@
41 <property name="window_position">center-on-parent</property> 41 <property name="window_position">center-on-parent</property>
42 <property name="destroy_with_parent">True</property> 42 <property name="destroy_with_parent">True</property>
43 <property name="type_hint">dialog</property> 43 <property name="type_hint">dialog</property>
44 <signal name="response" handler="GNS_edit_pkey_dialog_response_cb" swapped="no"/>
45 <child internal-child="vbox"> 44 <child internal-child="vbox">
46 <object class="GtkVBox" id="edit_dialog_vbox"> 45 <object class="GtkVBox" id="edit_dialog_vbox">
47 <property name="visible">True</property> 46 <property name="visible">True</property>
diff --git a/contrib/gnunet_namestore_edit_ptr.glade b/contrib/gnunet_namestore_edit_ptr.glade
index 772587be..faf4e737 100644
--- a/contrib/gnunet_namestore_edit_ptr.glade
+++ b/contrib/gnunet_namestore_edit_ptr.glade
@@ -41,7 +41,6 @@
41 <property name="window_position">center-on-parent</property> 41 <property name="window_position">center-on-parent</property>
42 <property name="destroy_with_parent">True</property> 42 <property name="destroy_with_parent">True</property>
43 <property name="type_hint">dialog</property> 43 <property name="type_hint">dialog</property>
44 <signal name="response" handler="GNS_edit_ptr_dialog_response_cb" swapped="no"/>
45 <child internal-child="vbox"> 44 <child internal-child="vbox">
46 <object class="GtkVBox" id="edit_dialog_vbox"> 45 <object class="GtkVBox" id="edit_dialog_vbox">
47 <property name="visible">True</property> 46 <property name="visible">True</property>
diff --git a/contrib/gnunet_namestore_edit_soa.glade b/contrib/gnunet_namestore_edit_soa.glade
index 851fbd82..51227da8 100644
--- a/contrib/gnunet_namestore_edit_soa.glade
+++ b/contrib/gnunet_namestore_edit_soa.glade
@@ -70,7 +70,6 @@
70 <property name="window_position">center-on-parent</property> 70 <property name="window_position">center-on-parent</property>
71 <property name="destroy_with_parent">True</property> 71 <property name="destroy_with_parent">True</property>
72 <property name="type_hint">dialog</property> 72 <property name="type_hint">dialog</property>
73 <signal name="response" handler="GNS_edit_soa_dialog_response_cb" swapped="no"/>
74 <child internal-child="vbox"> 73 <child internal-child="vbox">
75 <object class="GtkVBox" id="edit_dialog_vbox"> 74 <object class="GtkVBox" id="edit_dialog_vbox">
76 <property name="visible">True</property> 75 <property name="visible">True</property>
diff --git a/contrib/gnunet_namestore_edit_srv.glade b/contrib/gnunet_namestore_edit_srv.glade
index 8bb71dcb..a7f39626 100644
--- a/contrib/gnunet_namestore_edit_srv.glade
+++ b/contrib/gnunet_namestore_edit_srv.glade
@@ -56,7 +56,6 @@
56 <property name="window_position">center-on-parent</property> 56 <property name="window_position">center-on-parent</property>
57 <property name="destroy_with_parent">True</property> 57 <property name="destroy_with_parent">True</property>
58 <property name="type_hint">dialog</property> 58 <property name="type_hint">dialog</property>
59 <signal name="response" handler="GNS_edit_srv_dialog_response_cb" swapped="no"/>
60 <child internal-child="vbox"> 59 <child internal-child="vbox">
61 <object class="GtkVBox" id="edit_dialog_vbox"> 60 <object class="GtkVBox" id="edit_dialog_vbox">
62 <property name="visible">True</property> 61 <property name="visible">True</property>
diff --git a/contrib/gnunet_namestore_edit_txt.glade b/contrib/gnunet_namestore_edit_txt.glade
index 53d34fe4..9973f1ab 100644
--- a/contrib/gnunet_namestore_edit_txt.glade
+++ b/contrib/gnunet_namestore_edit_txt.glade
@@ -41,7 +41,6 @@
41 <property name="window_position">center-on-parent</property> 41 <property name="window_position">center-on-parent</property>
42 <property name="destroy_with_parent">True</property> 42 <property name="destroy_with_parent">True</property>
43 <property name="type_hint">dialog</property> 43 <property name="type_hint">dialog</property>
44 <signal name="response" handler="GNS_edit_txt_dialog_response_cb" swapped="no"/>
45 <child internal-child="vbox"> 44 <child internal-child="vbox">
46 <object class="GtkVBox" id="edit_dialog_vbox"> 45 <object class="GtkVBox" id="edit_dialog_vbox">
47 <property name="visible">True</property> 46 <property name="visible">True</property>
diff --git a/contrib/gnunet_namestore_edit_vpn.glade b/contrib/gnunet_namestore_edit_vpn.glade
index 45155c3b..c2c7ff1c 100644
--- a/contrib/gnunet_namestore_edit_vpn.glade
+++ b/contrib/gnunet_namestore_edit_vpn.glade
@@ -41,7 +41,6 @@
41 <property name="window_position">center-on-parent</property> 41 <property name="window_position">center-on-parent</property>
42 <property name="destroy_with_parent">True</property> 42 <property name="destroy_with_parent">True</property>
43 <property name="type_hint">dialog</property> 43 <property name="type_hint">dialog</property>
44 <signal name="response" handler="GNS_edit_vpn_dialog_response_cb" swapped="no"/>
45 <child internal-child="vbox"> 44 <child internal-child="vbox">
46 <object class="GtkVBox" id="edit_dialog_vbox"> 45 <object class="GtkVBox" id="edit_dialog_vbox">
47 <property name="visible">True</property> 46 <property name="visible">True</property>
diff --git a/src/include/gnunet_gtk.h b/src/include/gnunet_gtk.h
index 523524d6..ec500705 100644
--- a/src/include/gnunet_gtk.h
+++ b/src/include/gnunet_gtk.h
@@ -107,6 +107,22 @@ GNUNET_GTK_installation_get_path (enum GNUNET_OS_InstallationPathKind dirkind);
107/* **************** Glade/Gtk helpers *************** */ 107/* **************** Glade/Gtk helpers *************** */
108 108
109/** 109/**
110 * Create an initialize a new builder based on the
111 * GNUnet-GTK glade file.
112 *
113 * @param filename name of the resource file to load
114 * @param user_data user_data to pass to signal handlers,
115 * use "NULL" to pass the GtkBuilder itself.
116 * @param cb function to call before connecting signals
117 * @return NULL on error
118 */
119GtkBuilder *
120GNUNET_GTK_get_new_builder2 (const char *filename,
121 void *user_data,
122 GtkBuilderConnectFunc cb);
123
124
125/**
110 * Create an initialize a new builder based on the GNUnet-GTK glade 126 * Create an initialize a new builder based on the GNUnet-GTK glade
111 * file. 127 * file.
112 * 128 *
@@ -115,9 +131,7 @@ GNUNET_GTK_installation_get_path (enum GNUNET_OS_InstallationPathKind dirkind);
115 * use "NULL" to pass the GtkBuilder itself. 131 * use "NULL" to pass the GtkBuilder itself.
116 * @return NULL on error 132 * @return NULL on error
117 */ 133 */
118GtkBuilder * 134#define GNUNET_GTK_get_new_builder(filename,user_data) GNUNET_GTK_get_new_builder2(filename,user_data,NULL)
119GNUNET_GTK_get_new_builder (const char *filename,
120 void *user_data);
121 135
122 136
123/** 137/**
diff --git a/src/include/gnunet_gtk_namestore_plugin.h b/src/include/gnunet_gtk_namestore_plugin.h
index c7a2d237..79ef4202 100644
--- a/src/include/gnunet_gtk_namestore_plugin.h
+++ b/src/include/gnunet_gtk_namestore_plugin.h
@@ -32,26 +32,125 @@
32 32
33 33
34/** 34/**
35 * Context for edit operations. 35 * Context for edit operations and environment for plugins.
36 * Typical plugins will only use the @e check_validity callback.
36 */ 37 */
37struct GNUNET_GTK_NAMESTORE_PluginEnvironment 38struct GNUNET_GTK_NAMESTORE_PluginEnvironment
38{ 39{
39 /**
40 * Closure to pass to @e check_validity.
41 */
42 void *cls;
43 40
44 /** 41 /**
45 * Function that should be called by the plugin whenever values in 42 * Function that should be called by the plugin whenever values in
46 * the dialog were edited. It will check the validity of the dialog 43 * the dialog were edited. It will check the validity of the dialog
47 * and update the "save" button accordingly. 44 * and update the "save" button accordingly.
48 */ 45 */
49 void (*check_validity)(void *cls); 46 void (*check_validity)(struct GNUNET_GTK_NAMESTORE_PluginEnvironment *edc);
47
48 /**
49 * Builder for the dialog.
50 */
51 GtkBuilder *builder;
52
53 /**
54 * Main dialog window.
55 */
56 GtkDialog *dialog;
57
58 /**
59 * Where in the tree view are we editing?
60 */
61 struct RecordInfo *ri;
62
63 /**
64 * Name of the record.
65 */
66 gchar *name;
67
68 /**
69 * Value of the record in string format.
70 */
71 gchar *n_value;
72
73 /**
74 * Name of the zone into which the record should be placed.
75 */
76 gchar *new_zone_option;
77
78 /**
79 * Ego of the zone into which the record should be placed.
80 */
81 struct GNUNET_IDENTITY_Ego *ego;
82
83 /**
84 * List of all zones.
85 */
86 GtkListStore *zone_liststore;
87
88 /**
89 * The plugin we used to edit the value.
90 */
91 struct GNUNET_GTK_NAMESTORE_PluginFunctions *plugin;
92
93 /**
94 * Name of the plugin library.
95 */
96 char *liblow;
97
98 /**
99 * Expiration time value (absolute or relative).
100 */
101 guint64 n_exp_time;
102
103 /**
104 * Offset of the record we are editing in the 'rd' list of 'ri'.
105 */
106 unsigned int off;
107
108 /**
109 * Flag indicating if the old record was in the namestore.
110 */
111 int old_record_in_namestore;
112
113 /**
114 * Type of the record.
115 */
116 uint32_t record_type;
117
118 /**
119 * Is this record 'public'?
120 */
121 gboolean n_public;
122
123 /**
124 * Is the expiration time relative?
125 */
126 gboolean n_is_relative;
127
128 /**
129 * Is this record a shadow record?
130 */
131 gboolean n_is_shadow;
50 132
51}; 133};
52 134
53 135
54/** 136/**
137 * Symbol to give to the GtkBuilder for resolution.
138 */
139struct GNUNET_GTK_NAMESTORE_Symbol
140{
141 /**
142 * Name of the symbol.
143 */
144 const char *name;
145
146 /**
147 * Corresponding callback.
148 */
149 GCallback cb;
150};
151
152
153/**
55 * Each plugin is required to return a pointer to a struct of this 154 * Each plugin is required to return a pointer to a struct of this
56 * type as the return value from its entry point. 155 * type as the return value from its entry point.
57 */ 156 */
@@ -77,6 +176,11 @@ struct GNUNET_GTK_NAMESTORE_PluginFunctions
77 const char *dialog_widget_name; 176 const char *dialog_widget_name;
78 177
79 /** 178 /**
179 * NULL-terminated array of symbols to add to the gtk builder.
180 */
181 const struct GNUNET_GTK_NAMESTORE_Symbol *symbols;
182
183 /**
80 * Function that will be called to initialize the builder's 184 * Function that will be called to initialize the builder's
81 * widgets from the existing record (if there is one). 185 * widgets from the existing record (if there is one).
82 * The `n_value` is the existing value of the record as a string. 186 * The `n_value` is the existing value of the record as a string.
diff --git a/src/lib/glade.c b/src/lib/glade.c
index 407e23f0..1d829788 100644
--- a/src/lib/glade.c
+++ b/src/lib/glade.c
@@ -99,11 +99,13 @@ GNUNET_GTK_get_tree_string (GtkTreeView * treeview, GtkTreePath * treepath,
99 * @param filename name of the resource file to load 99 * @param filename name of the resource file to load
100 * @param user_data user_data to pass to signal handlers, 100 * @param user_data user_data to pass to signal handlers,
101 * use "NULL" to pass the GtkBuilder itself. 101 * use "NULL" to pass the GtkBuilder itself.
102 * @param cb function to call before connecting signals
102 * @return NULL on error 103 * @return NULL on error
103 */ 104 */
104GtkBuilder * 105GtkBuilder *
105GNUNET_GTK_get_new_builder (const char *filename, 106GNUNET_GTK_get_new_builder2 (const char *filename,
106 void *user_data) 107 void *user_data,
108 GtkBuilderConnectFunc cb)
107{ 109{
108 char *glade_path; 110 char *glade_path;
109 GtkBuilder *ret; 111 GtkBuilder *ret;
@@ -111,17 +113,25 @@ GNUNET_GTK_get_new_builder (const char *filename,
111 113
112 ret = gtk_builder_new (); 114 ret = gtk_builder_new ();
113 gtk_builder_set_translation_domain (ret, "gnunet-gtk"); 115 gtk_builder_set_translation_domain (ret, "gnunet-gtk");
114 GNUNET_asprintf (&glade_path, "%s%s", GNUNET_GTK_get_data_dir (), filename); 116 GNUNET_asprintf (&glade_path, "%s%s",
117 GNUNET_GTK_get_data_dir (),
118 filename);
115 error = NULL; 119 error = NULL;
116 if (0 == gtk_builder_add_from_file (ret, glade_path, &error)) 120 if (0 == gtk_builder_add_from_file (ret, glade_path, &error))
117 { 121 {
118 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Failed to load `%s': %s\n"), 122 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
123 _("Failed to load `%s': %s\n"),
119 glade_path, error->message); 124 glade_path, error->message);
120 g_error_free (error); 125 g_error_free (error);
121 GNUNET_free (glade_path); 126 GNUNET_free (glade_path);
122 return NULL; 127 return NULL;
123 } 128 }
124 gtk_builder_connect_signals (ret, (user_data == NULL) ? ret : user_data); 129 if (NULL == user_data)
130 user_data = ret;
131 if (NULL != cb)
132 gtk_builder_connect_signals_full (ret, cb, user_data);
133 else
134 gtk_builder_connect_signals (ret, user_data);
125 GNUNET_free (glade_path); 135 GNUNET_free (glade_path);
126 return ret; 136 return ret;
127} 137}
diff --git a/src/namestore/Makefile.am b/src/namestore/Makefile.am
index 000df2fd..c70b54ca 100644
--- a/src/namestore/Makefile.am
+++ b/src/namestore/Makefile.am
@@ -12,9 +12,10 @@ bin_PROGRAMS = gnunet-namestore-gtk
12 12
13gnunet_namestore_gtk_SOURCES = \ 13gnunet_namestore_gtk_SOURCES = \
14 gnunet-namestore-gtk.c \ 14 gnunet-namestore-gtk.c \
15 gnunet-namestore-gtk_edit.c gnunet-namestore-gtk_edit.h 15 gnunet-namestore-gtk_edit.c
16gnunet_namestore_gtk_LDADD = \ 16gnunet_namestore_gtk_LDADD = \
17 $(top_builddir)/src/lib/libgnunetgtk.la \ 17 $(top_builddir)/src/lib/libgnunetgtk.la \
18 -lgmodule-2.0 \
18 @GTK_LIBS@ @GNUNET_LIBS@ @GLADE_LIBS@ @QR_LIBS@ \ 19 @GTK_LIBS@ @GNUNET_LIBS@ @GLADE_LIBS@ @QR_LIBS@ \
19 $(WINLIBS) \ 20 $(WINLIBS) \
20 -lgnunetutil -lgnunetgnsrecord -lgnunetnamestore -lgnunetdnsparser \ 21 -lgnunetutil -lgnunetgnsrecord -lgnunetnamestore -lgnunetdnsparser \
diff --git a/src/namestore/gnunet-namestore-gtk.c b/src/namestore/gnunet-namestore-gtk.c
index eb08557b..4483b0c2 100644
--- a/src/namestore/gnunet-namestore-gtk.c
+++ b/src/namestore/gnunet-namestore-gtk.c
@@ -24,7 +24,8 @@
24 * @brief edit GNS zones 24 * @brief edit GNS zones
25 */ 25 */
26#include "gnunet_gtk.h" 26#include "gnunet_gtk.h"
27#include "gnunet-namestore-gtk_edit.h" 27#include "gnunet_gtk_namestore_plugin.h"
28#include <gmodule.h>
28#include <gnunet/gnunet_gnsrecord_lib.h> 29#include <gnunet/gnunet_gnsrecord_lib.h>
29#include <gnunet/gnunet_gns_service.h> 30#include <gnunet/gnunet_gns_service.h>
30#include <gnunet/gnunet_identity_service.h> 31#include <gnunet/gnunet_identity_service.h>
@@ -183,6 +184,25 @@ enum LIST_COLUMNS
183 184
184 185
185/** 186/**
187 * Columns in the zone list store.
188 */
189enum ZONE_COLUMNS
190{
191
192 /**
193 * A gchararray
194 */
195 ZONE_LS_NAME = 0,
196
197
198 /**
199 * A `struct GNUNET_IDENTITY_Ego`
200 */
201 ZONE_LS_EGO = 1
202};
203
204
205/**
186 * Closure for 'operation_done_cont'. 206 * Closure for 'operation_done_cont'.
187 */ 207 */
188struct OperationContext 208struct OperationContext
@@ -230,7 +250,7 @@ struct MoveOperationContext
230 /** 250 /**
231 * Info from editing dialog. 251 * Info from editing dialog.
232 */ 252 */
233 struct EditDialogContext *edc; 253 struct GNUNET_GTK_NAMESTORE_PluginEnvironment *edc;
234 254
235 /** 255 /**
236 * Private key of target zone. 256 * Private key of target zone.
@@ -535,8 +555,8 @@ setup_qrcode ()
535 */ 555 */
536void 556void
537gnunet_namestore_gtk_qr_save_as_dialog_response_cb (GtkDialog *dialog, 557gnunet_namestore_gtk_qr_save_as_dialog_response_cb (GtkDialog *dialog,
538 gint response_id, 558 gint response_id,
539 gpointer user_data) 559 gpointer user_data)
540{ 560{
541#if HAVE_QRENCODE_H 561#if HAVE_QRENCODE_H
542 GtkBuilder *builder = user_data; 562 GtkBuilder *builder = user_data;
@@ -577,7 +597,7 @@ gnunet_namestore_gtk_qr_save_as_dialog_response_cb (GtkDialog *dialog,
577 */ 597 */
578void 598void
579gnunet_namestore_gtk_qr_saveas_button_clicked_cb (GtkButton *button, 599gnunet_namestore_gtk_qr_saveas_button_clicked_cb (GtkButton *button,
580 gpointer user_data) 600 gpointer user_data)
581{ 601{
582 GtkBuilder *builder; 602 GtkBuilder *builder;
583 GtkWindow *dialog; 603 GtkWindow *dialog;
@@ -589,7 +609,7 @@ gnunet_namestore_gtk_qr_saveas_button_clicked_cb (GtkButton *button,
589 pseu = gtk_entry_get_text (GTK_ENTRY(entry)); 609 pseu = gtk_entry_get_text (GTK_ENTRY(entry));
590 builder = 610 builder =
591 GNUNET_GTK_get_new_builder ("gnunet_namestore_gtk_qr_save_as_dialog.glade", 611 GNUNET_GTK_get_new_builder ("gnunet_namestore_gtk_qr_save_as_dialog.glade",
592 NULL); 612 NULL);
593 if (NULL == builder) 613 if (NULL == builder)
594 { 614 {
595 GNUNET_break (0); 615 GNUNET_break (0);
@@ -782,7 +802,7 @@ show_error_message (const char *title,
782 * @param edc resources to free 802 * @param edc resources to free
783 */ 803 */
784static void 804static void
785free_edit_dialog_context (struct EditDialogContext *edc) 805free_edit_dialog_context (struct GNUNET_GTK_NAMESTORE_PluginEnvironment *edc)
786{ 806{
787 g_free (edc->name); 807 g_free (edc->name);
788 g_free (edc->n_value); 808 g_free (edc->n_value);
@@ -804,7 +824,7 @@ merge_with_existing_records (void *cls,
804 const struct GNUNET_GNSRECORD_Data *rd) 824 const struct GNUNET_GNSRECORD_Data *rd)
805{ 825{
806 struct MoveOperationContext *moc = cls; 826 struct MoveOperationContext *moc = cls;
807 struct EditDialogContext *edc = moc->edc; 827 struct GNUNET_GTK_NAMESTORE_PluginEnvironment *edc = moc->edc;
808 struct GNUNET_GNSRECORD_Data rd_new[rd_count + 1]; 828 struct GNUNET_GNSRECORD_Data rd_new[rd_count + 1];
809 struct OperationContext *oc; 829 struct OperationContext *oc;
810 830
@@ -883,7 +903,7 @@ handle_records_for_merge (void *cls,
883 * @param ret return code of the dialog 903 * @param ret return code of the dialog
884 */ 904 */
885static void 905static void
886edit_dialog_continuation (struct EditDialogContext *edc, 906edit_dialog_continuation (struct GNUNET_GTK_NAMESTORE_PluginEnvironment *edc,
887 GtkResponseType ret) 907 GtkResponseType ret)
888{ 908{
889 struct RecordInfo *ri = edc->ri; 909 struct RecordInfo *ri = edc->ri;
@@ -894,6 +914,17 @@ edit_dialog_continuation (struct EditDialogContext *edc,
894 size_t data_size; 914 size_t data_size;
895 struct OperationContext *oc; 915 struct OperationContext *oc;
896 916
917 if (NULL != edc->plugin)
918 {
919 GNUNET_PLUGIN_unload (edc->liblow,
920 edc->plugin);
921 edc->plugin = NULL;
922 }
923 if (NULL != edc->liblow)
924 {
925 GNUNET_free (edc->liblow);
926 edc->liblow = NULL;
927 }
897 if ( (NULL != ri) && 928 if ( (NULL != ri) &&
898 (GNUNET_OK != 929 (GNUNET_OK !=
899 GNUNET_GNSRECORD_records_deserialize (ri->data_size, 930 GNUNET_GNSRECORD_records_deserialize (ri->data_size,
@@ -1044,6 +1075,440 @@ edit_dialog_continuation (struct EditDialogContext *edc,
1044 1075
1045 1076
1046/** 1077/**
1078 * Disable 'save' button, dialog state is not acceptable.
1079 *
1080 * @param edc dialog to modify
1081 */
1082static void
1083edit_dialog_disable_save (struct GNUNET_GTK_NAMESTORE_PluginEnvironment *edc)
1084{
1085 gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (edc->builder,
1086 "edit_dialog_save_button")),
1087 FALSE);
1088}
1089
1090
1091/**
1092 * Enable 'save' button, dialog state is acceptable.
1093 *
1094 * @param edc dialog to modify
1095 */
1096static void
1097edit_dialog_enable_save (struct GNUNET_GTK_NAMESTORE_PluginEnvironment *edc)
1098{
1099 gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (edc->builder,
1100 "edit_dialog_save_button")),
1101 TRUE);
1102}
1103
1104
1105/**
1106 * Function that should be called by the plugin whenever values in
1107 * the dialog were edited. It will check the validity of the dialog
1108 * and update the "save" button accordingly.
1109 *
1110 * @param edc the plugin environment
1111 */
1112static void
1113check_validity (struct GNUNET_GTK_NAMESTORE_PluginEnvironment *edc)
1114{
1115
1116 GtkEditable *entry;
1117 const gchar *name;
1118
1119 /* check name */
1120 entry = GTK_EDITABLE (gtk_builder_get_object (edc->builder,
1121 "edit_dialog_name_entry"));
1122 name = gtk_editable_get_chars (entry, 0, -1);
1123 if ( (GNUNET_OK != edc->plugin->validate (edc->plugin->cls,
1124 edc->builder)) ||
1125 ( (GNUNET_SYSERR == GNUNET_DNSPARSER_check_label (name)) &&
1126 (0 != strcmp (name, GNUNET_GNS_MASTERZONE_STR))) )
1127 {
1128 edit_dialog_disable_save (edc);
1129 return;
1130 }
1131 edit_dialog_enable_save (edc);
1132}
1133
1134
1135/**
1136 * Setup the zone combobox.
1137 *
1138 * @param edc dialog to setup the combo box for
1139 */
1140static void
1141setup_zone (struct GNUNET_GTK_NAMESTORE_PluginEnvironment *edc)
1142{
1143 GtkTreeIter iter;
1144 GtkComboBox *cb;
1145 gchar *name;
1146
1147 cb = GTK_COMBO_BOX (gtk_builder_get_object (edc->builder,
1148 "edit_dialog_zone_combobox"));
1149
1150 gtk_combo_box_set_model (cb,
1151 GTK_TREE_MODEL (edc->zone_liststore));
1152 GNUNET_assert (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (edc->zone_liststore),
1153 &iter));
1154 do {
1155 gtk_tree_model_get (GTK_TREE_MODEL (edc->zone_liststore),
1156 &iter,
1157 ZONE_LS_NAME, &name,
1158 -1);
1159 if (0 == strcmp (name,
1160 edc->new_zone_option))
1161 {
1162 g_free (name);
1163 break;
1164 }
1165 g_free (name);
1166 } while (gtk_tree_model_iter_next (GTK_TREE_MODEL (edc->zone_liststore),
1167 &iter));
1168 gtk_combo_box_set_active_iter (cb,
1169 &iter);
1170}
1171
1172
1173/**
1174 * Initialize widgets of the edit dialog that are the same regardless of
1175 * the type of the record.
1176 *
1177 * @param edc dialog context
1178 */
1179static void
1180edit_dialog_setup_common_elements (struct GNUNET_GTK_NAMESTORE_PluginEnvironment *edc)
1181{
1182 GtkComboBox *cb;
1183 GtkListStore *ls;
1184 GtkTreeIter iter;
1185 struct GNUNET_TIME_Absolute at;
1186 struct GNUNET_TIME_Relative rt;
1187 time_t tp;
1188 struct tm *ymd;
1189 GtkCalendar *cal;
1190
1191 if (GNUNET_YES !=
1192 edc->old_record_in_namestore)
1193 {
1194 gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (edc->builder,
1195 "edit_dialog_delete_button")));
1196 edit_dialog_disable_save (edc);
1197 }
1198 gtk_entry_set_text (GTK_ENTRY (gtk_builder_get_object (edc->builder,
1199 "edit_dialog_name_entry")),
1200 edc->name);
1201 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (edc->builder,
1202 "edit_dialog_options_public_checkbutton")),
1203 edc->n_public);
1204 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (edc->builder,
1205 "edit_dialog_options_shadow_checkbutton")),
1206 edc->n_is_shadow);
1207 if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us == edc->n_exp_time)
1208 {
1209 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (edc->builder,
1210 "edit_dialog_expiration_never_radiobutton")),
1211 TRUE);
1212 gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (edc->builder,
1213 "edit_dialog_expiration_absolute_calendar")));
1214 gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (edc->builder,
1215 "edit_dialog_expiration_absolute_hbox")));
1216 gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (edc->builder,
1217 "edit_dialog_expiration_relative_combobox")));
1218 }
1219 if ( (edc->n_is_relative) &&
1220 (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != edc->n_exp_time) )
1221 {
1222 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (edc->builder,
1223 "edit_dialog_expiration_relative_radiobutton")),
1224 TRUE);
1225 gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (edc->builder,
1226 "edit_dialog_expiration_absolute_calendar")));
1227 gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (edc->builder,
1228 "edit_dialog_expiration_absolute_hbox")));
1229 rt.rel_value_us = edc->n_exp_time;
1230 }
1231 else
1232 {
1233 /* select a sane default */
1234 rt = GNUNET_TIME_UNIT_DAYS;
1235 }
1236 cb = GTK_COMBO_BOX (gtk_builder_get_object (edc->builder,
1237 "edit_dialog_expiration_relative_combobox"));
1238 ls = GTK_LIST_STORE (gtk_combo_box_get_model (cb));
1239 gtk_list_store_insert_with_values (ls, &iter,
1240 -1 /* position: append */,
1241 0, GNUNET_STRINGS_relative_time_to_string (rt, GNUNET_NO),
1242 -1);
1243 gtk_combo_box_set_active_iter (cb, &iter);
1244 if ( (! edc->n_is_relative) &&
1245 (GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us != edc->n_exp_time) )
1246 {
1247 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (edc->builder,
1248 "edit_dialog_expiration_absolute_radiobutton")),
1249 TRUE);
1250
1251 gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (edc->builder,
1252 "edit_dialog_expiration_relative_combobox")));
1253 at.abs_value_us = edc->n_exp_time;
1254 }
1255 else
1256 {
1257 /* select a sane default: right now */
1258 at = GNUNET_TIME_absolute_get ();
1259 }
1260 tp = (time_t) (at.abs_value_us / 1000000LL); /* convert to seconds */
1261 ymd = gmtime (&tp);
1262 cal = GTK_CALENDAR (gtk_builder_get_object (edc->builder,
1263 "edit_dialog_expiration_absolute_calendar"));
1264 gtk_calendar_select_month (cal,
1265 ymd->tm_mon,
1266 ymd->tm_year + 1900);
1267 gtk_calendar_mark_day (cal,
1268 ymd->tm_mday);
1269 gtk_spin_button_set_value (GTK_SPIN_BUTTON (gtk_builder_get_object (edc->builder,
1270 "edit_dialog_expiration_absolute_hours_spinbutton")),
1271 (double) ymd->tm_hour);
1272 gtk_spin_button_set_value (GTK_SPIN_BUTTON (gtk_builder_get_object (edc->builder,
1273 "edit_dialog_expiration_absolute_minutes_spinbutton")),
1274 (double) ymd->tm_min);
1275 gtk_spin_button_set_value (GTK_SPIN_BUTTON (gtk_builder_get_object (edc->builder,
1276 "edit_dialog_expiration_absolute_seconds_spinbutton")),
1277 (double) ymd->tm_sec);
1278}
1279
1280
1281/**
1282 * Perform the reverse of the #edit_dialog_setup_common_elements() function,
1283 * that is, extract the values from the (common) widgets and store the
1284 * values in @a edc.
1285 *
1286 * @param edc edit dialog to extract data from
1287 */
1288static void
1289edit_dialog_putes_common_elements (struct GNUNET_GTK_NAMESTORE_PluginEnvironment *edc)
1290{
1291 const char *rt_s;
1292 struct GNUNET_TIME_Relative rt;
1293 GtkComboBox *cb;
1294 GtkTreeModel *tm;
1295 GtkTreeIter iter;
1296 gchar *opt;
1297 struct GNUNET_IDENTITY_Ego *ego;
1298
1299 /* is public flag */
1300 edc->n_public = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (edc->builder,
1301 "edit_dialog_options_public_checkbutton")));
1302 /* is shadow flag */
1303 edc->n_is_shadow = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (edc->builder,
1304 "edit_dialog_options_shadow_checkbutton")));
1305
1306 /* 'forever' expiration time */
1307 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (edc->builder,
1308 "edit_dialog_expiration_never_radiobutton"))))
1309 {
1310 edc->n_exp_time = GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us;
1311 edc->n_is_relative = TRUE; /* doesn't matter, but make sure it is well-defined anyway */
1312 }
1313
1314 /* 'relative' expiration time */
1315 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (edc->builder,
1316 "edit_dialog_expiration_relative_radiobutton"))))
1317 {
1318 cb = GTK_COMBO_BOX (gtk_builder_get_object (edc->builder,
1319 "edit_dialog_expiration_relative_combobox"));
1320 tm = gtk_combo_box_get_model (cb);
1321 if (! gtk_combo_box_get_active_iter (cb, &iter))
1322 {
1323 GNUNET_break (0);
1324 return;
1325 }
1326 gtk_tree_model_get (tm, &iter,
1327 0, &rt_s,
1328 -1);
1329 GNUNET_break (GNUNET_YES ==
1330 GNUNET_STRINGS_fancy_time_to_relative (rt_s,
1331 &rt));
1332 edc->n_exp_time = rt.rel_value_us;
1333 edc->n_is_relative = TRUE;
1334 }
1335
1336 /* 'absolute' expiration time */
1337 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (edc->builder,
1338 "edit_dialog_expiration_absolute_radiobutton"))))
1339 {
1340 guint year;
1341 guint month;
1342 guint day;
1343 guint hour;
1344 guint minute;
1345 guint second;
1346 char fancydate[128];
1347 struct GNUNET_TIME_Absolute atime;
1348
1349 gtk_calendar_get_date (GTK_CALENDAR (gtk_builder_get_object (edc->builder,
1350 "edit_dialog_expiration_absolute_calendar")),
1351 &year, &month, &day);
1352 hour = gtk_spin_button_get_value (GTK_SPIN_BUTTON (gtk_builder_get_object (edc->builder,
1353 "edit_dialog_expiration_absolute_hours_spinbutton")));
1354 minute = gtk_spin_button_get_value (GTK_SPIN_BUTTON (gtk_builder_get_object (edc->builder,
1355 "edit_dialog_expiration_absolute_minutes_spinbutton")));
1356 second = gtk_spin_button_get_value (GTK_SPIN_BUTTON (gtk_builder_get_object (edc->builder,
1357 "edit_dialog_expiration_absolute_seconds_spinbutton")));
1358 GNUNET_snprintf (fancydate,
1359 sizeof (fancydate),
1360 "%u-%u-%u %u:%u:%u",
1361 (unsigned int) year,
1362 (unsigned int) month + 1,
1363 (unsigned int) day,
1364 (unsigned int) hour,
1365 (unsigned int) minute,
1366 (unsigned int) second);
1367 GNUNET_break (GNUNET_OK ==
1368 GNUNET_STRINGS_fancy_time_to_absolute (fancydate,
1369 &atime));
1370 edc->n_exp_time = atime.abs_value_us;
1371 edc->n_is_relative = FALSE;
1372 }
1373
1374 /* extract target zone! */
1375 cb = GTK_COMBO_BOX (gtk_builder_get_object (edc->builder,
1376 "edit_dialog_zone_combobox"));
1377 tm = gtk_combo_box_get_model (cb);
1378 if (! gtk_combo_box_get_active_iter (cb, &iter))
1379 {
1380 GNUNET_break (0);
1381 }
1382 else
1383 {
1384 gtk_tree_model_get (tm, &iter,
1385 ZONE_LS_NAME, &opt,
1386 ZONE_LS_EGO, &ego,
1387 -1);
1388 if (NULL == opt)
1389 {
1390 GNUNET_break (0);
1391 }
1392 else
1393 {
1394 g_free (edc->new_zone_option);
1395 edc->new_zone_option = g_strdup (opt);
1396 g_free (opt);
1397 edc->ego = ego;
1398 }
1399 }
1400}
1401
1402
1403/**
1404 * Editing dialog was closed, get the data and call the
1405 * continuation.
1406 *
1407 * @param dialog editing dialog
1408 * @param response_id action that caused the dialog to be closed
1409 * @param user_data the `struct GNUNET_GTK_NAMESTORE_PluginEnvironment`
1410 */
1411static void
1412edit_dialog_response_cb (GtkDialog *dialog,
1413 gint response_id,
1414 gpointer user_data)
1415{
1416 struct GNUNET_GTK_NAMESTORE_PluginEnvironment *edc = user_data;
1417
1418 if (GTK_RESPONSE_OK == response_id)
1419 {
1420 edit_dialog_putes_common_elements (edc);
1421 g_free (edc->n_value);
1422 edc->n_value = edc->plugin->store (edc->plugin->cls,
1423 edc->builder);
1424 }
1425 gtk_widget_destroy (GTK_WIDGET (edc->dialog));
1426 g_object_unref (edc->builder);
1427 edc->builder = NULL;
1428 edit_dialog_continuation (edc, response_id);
1429}
1430
1431
1432/**
1433 * Callback invoked from #GNUNET_GTK_get_new_builder2 to give
1434 * us a chance to add symbols from the plugin.
1435 *
1436 * @param builder the builder under construction
1437 * @param object object to bind signal to
1438 * @param signal_name name of the signal
1439 * @param handler_name name of the handler
1440 * @param connect_object a GObject, if non-NULL, use g_signal_connect_object()
1441 * @param flags GConnectFlags to use
1442 * @param user_data the `struct GNUNET_GTK_NAMESTORE_PluginEnvironment *`
1443 */
1444static void
1445add_symbols (GtkBuilder *builder,
1446 GObject *object,
1447 const gchar *signal_name,
1448 const gchar *handler_name,
1449 GObject *connect_object,
1450 GConnectFlags flags,
1451 gpointer user_data)
1452
1453{
1454 struct GNUNET_GTK_NAMESTORE_PluginEnvironment *edc = user_data;
1455 unsigned int i;
1456 GCallback cb;
1457 GModule *m;
1458
1459 cb = NULL;
1460 if (NULL != edc->plugin->symbols)
1461 {
1462 for (i=0; NULL != edc->plugin->symbols[i].name; i++)
1463 {
1464 if (0 == strcmp (handler_name,
1465 edc->plugin->symbols[i].name))
1466 {
1467 cb = edc->plugin->symbols[i].cb;
1468 break;
1469 }
1470 }
1471 }
1472 if (NULL == cb)
1473 {
1474 m = g_module_open (NULL, 0);
1475 if (! g_module_symbol (m,
1476 handler_name,
1477 (void **) &cb))
1478 {
1479 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1480 _("Failed to find handler `%s'\n"),
1481 handler_name);
1482 g_module_close (m);
1483 return;
1484 }
1485 g_module_close (m);
1486 }
1487 if (NULL != connect_object)
1488 g_signal_connect_object (object,
1489 signal_name,
1490 cb,
1491 connect_object,
1492 flags);
1493 else if (flags & G_CONNECT_SWAPPED)
1494 g_signal_connect_swapped (object,
1495 signal_name,
1496 cb,
1497 user_data);
1498 else if (flags & G_CONNECT_AFTER)
1499 g_signal_connect_after (object,
1500 signal_name,
1501 cb,
1502 user_data);
1503 else
1504 g_signal_connect (object,
1505 signal_name,
1506 cb,
1507 user_data);
1508}
1509
1510
1511/**
1047 * Launch a record editing dialog. 1512 * Launch a record editing dialog.
1048 * 1513 *
1049 * @param n_type type of the record to edit 1514 * @param n_type type of the record to edit
@@ -1059,9 +1524,9 @@ launch_edit_dialog (gint n_type,
1059 struct RecordInfo *ri, 1524 struct RecordInfo *ri,
1060 unsigned int off) 1525 unsigned int off)
1061{ 1526{
1062 struct EditDialogContext *edc; 1527 struct GNUNET_GTK_NAMESTORE_PluginEnvironment *edc;
1063 1528
1064 edc = GNUNET_new (struct EditDialogContext); 1529 edc = GNUNET_new (struct GNUNET_GTK_NAMESTORE_PluginEnvironment);
1065 if ( (NULL != ri) && 1530 if ( (NULL != ri) &&
1066 (off < ri->rd_count) ) 1531 (off < ri->rd_count) )
1067 { 1532 {
@@ -1090,56 +1555,52 @@ launch_edit_dialog (gint n_type,
1090 edc->name = GNUNET_strdup (name); 1555 edc->name = GNUNET_strdup (name);
1091 edc->new_zone_option = g_strdup (current_zone_option); 1556 edc->new_zone_option = g_strdup (current_zone_option);
1092 edc->record_type = n_type; 1557 edc->record_type = n_type;
1093 edc->cont = &edit_dialog_continuation;
1094 edc->zone_liststore = zone_liststore; 1558 edc->zone_liststore = zone_liststore;
1095 switch (n_type) 1559 edc->check_validity = &check_validity;
1560 GNUNET_asprintf (&edc->liblow,
1561 "libgnunet_plugin_gtk_namestore_%s",
1562 GNUNET_GNSRECORD_number_to_typename (n_type));
1563 GNUNET_STRINGS_utf8_tolower (edc->liblow,
1564 edc->liblow);
1565 edc->plugin = GNUNET_PLUGIN_load (edc->liblow, edc);
1566 if (NULL == edc->plugin)
1096 { 1567 {
1097 case GNUNET_DNSPARSER_TYPE_A: 1568 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1098 GNS_edit_dialog_a (edc); 1569 _("Failed to load plugin for record type %d\n"),
1099 break; 1570 (int) n_type);
1100 case GNUNET_DNSPARSER_TYPE_AAAA:
1101 GNS_edit_dialog_aaaa (edc);
1102 break;
1103 case GNUNET_DNSPARSER_TYPE_CNAME:
1104 GNS_edit_dialog_cname (edc);
1105 break;
1106 case GNUNET_GNSRECORD_TYPE_LEHO:
1107 GNS_edit_dialog_leho (edc);
1108 break;
1109 case GNUNET_GNSRECORD_TYPE_PHONE:
1110 GNS_edit_dialog_phone (edc);
1111 break;
1112 case GNUNET_GNSRECORD_TYPE_PKEY:
1113 GNS_edit_dialog_pkey (edc);
1114 break;
1115 case GNUNET_DNSPARSER_TYPE_PTR:
1116 GNS_edit_dialog_ptr (edc);
1117 break;
1118 case GNUNET_DNSPARSER_TYPE_MX:
1119 GNS_edit_dialog_mx (edc);
1120 break;
1121 case GNUNET_GNSRECORD_TYPE_GNS2DNS:
1122 GNS_edit_dialog_gns2dns (edc);
1123 break;
1124 case GNUNET_DNSPARSER_TYPE_SOA:
1125 GNS_edit_dialog_soa (edc);
1126 break;
1127 case GNUNET_DNSPARSER_TYPE_SRV:
1128 GNS_edit_dialog_srv (edc);
1129 break;
1130 case GNUNET_DNSPARSER_TYPE_TXT:
1131 GNS_edit_dialog_txt (edc);
1132 break;
1133 case GNUNET_GNSRECORD_TYPE_VPN:
1134 GNS_edit_dialog_vpn (edc);
1135 break;
1136 case GNUNET_DNSPARSER_TYPE_TLSA:
1137 default:
1138 GNUNET_break (0);
1139 edit_dialog_continuation (edc, 1571 edit_dialog_continuation (edc,
1140 GTK_RESPONSE_CANCEL); 1572 GTK_RESPONSE_CANCEL);
1141 break; 1573 return;
1142 } 1574 }
1575 edc->builder = GNUNET_GTK_get_new_builder2 (edc->plugin->dialog_glade_filename,
1576 edc,
1577 &add_symbols);
1578 if (NULL == edc->builder)
1579 {
1580 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1581 _("Failed to load dialog resource `%s'\n"),
1582 edc->plugin->dialog_glade_filename);
1583 edit_dialog_continuation (edc, GTK_RESPONSE_CANCEL);
1584 return;
1585 }
1586 if (GNUNET_YES ==
1587 edc->old_record_in_namestore)
1588 {
1589 edc->plugin->load (edc->plugin->cls,
1590 edc->n_value,
1591 edc->builder);
1592 }
1593 edc->dialog = GTK_DIALOG (gtk_builder_get_object (edc->builder,
1594 edc->plugin->dialog_widget_name));
1595 g_signal_connect (edc->dialog,
1596 "response",
1597 G_CALLBACK (&edit_dialog_response_cb),
1598 edc);
1599 edit_dialog_setup_common_elements (edc);
1600 setup_zone (edc);
1601 gtk_dialog_set_default_response (edc->dialog,
1602 GTK_RESPONSE_OK);
1603 gtk_window_present (GTK_WINDOW (edc->dialog));
1143} 1604}
1144 1605
1145 1606
@@ -1186,7 +1647,7 @@ check_permissions (struct RecordInfo *ri,
1186 */ 1647 */
1187void 1648void
1188gnunet_namestore_gtk_popup_edit_button_activate_cb (GtkWidget *widget, 1649gnunet_namestore_gtk_popup_edit_button_activate_cb (GtkWidget *widget,
1189 gpointer user_data) 1650 gpointer user_data)
1190{ 1651{
1191 GtkTreeSelection *sel; 1652 GtkTreeSelection *sel;
1192 gint n_type; 1653 gint n_type;
@@ -1239,9 +1700,9 @@ gnunet_namestore_gtk_popup_edit_button_activate_cb (GtkWidget *widget,
1239 */ 1700 */
1240void 1701void
1241gnunet_namestore_gtk_type_cellrenderercombo_edited_cb (GtkCellRendererText *text, 1702gnunet_namestore_gtk_type_cellrenderercombo_edited_cb (GtkCellRendererText *text,
1242 gchar *path_string, 1703 gchar *path_string,
1243 gchar *new_text, 1704 gchar *new_text,
1244 gpointer user_data) 1705 gpointer user_data)
1245{ 1706{
1246 GtkTreeIter it; 1707 GtkTreeIter it;
1247 guint type; 1708 guint type;
@@ -2281,7 +2742,8 @@ main (int argc, char *const *argv)
2281 if (GNUNET_OK == 2742 if (GNUNET_OK ==
2282 GNUNET_GTK_main_loop_start ("gnunet-namestore-gtk", 2743 GNUNET_GTK_main_loop_start ("gnunet-namestore-gtk",
2283 "gnunet-namestore-gtk", argc, argv, 2744 "gnunet-namestore-gtk", argc, argv,
2284 options, "gnunet_namestore_gtk_main_window.glade", 2745 options,
2746 "gnunet_namestore_gtk_main_window.glade",
2285 &run)) 2747 &run))
2286 ret = gret; 2748 ret = gret;
2287 else 2749 else
@@ -2290,5 +2752,4 @@ main (int argc, char *const *argv)
2290} 2752}
2291 2753
2292 2754
2293
2294/* end of gnunet-namestore-gtk.c */ 2755/* end of gnunet-namestore-gtk.c */
diff --git a/src/namestore/gnunet-namestore-gtk_edit.c b/src/namestore/gnunet-namestore-gtk_edit.c
index 7fe0d27b..790f591b 100644
--- a/src/namestore/gnunet-namestore-gtk_edit.c
+++ b/src/namestore/gnunet-namestore-gtk_edit.c
@@ -20,78 +20,24 @@
20/** 20/**
21 * @file src/namestore/gnunet-namestore-gtk_edit.c 21 * @file src/namestore/gnunet-namestore-gtk_edit.c
22 * @author Christian Grothoff 22 * @author Christian Grothoff
23 * @brief editing dialogs for GNS records 23 * @brief common functions for editing dialogs for GNS records
24 */ 24 */
25#include "gnunet-namestore-gtk_edit.h" 25#include "gnunet_gtk.h"
26#include <gnunet/gnunet_gns_service.h> 26#include <gnunet/gnunet_gns_service.h>
27 27#include "gnunet_gtk_namestore_plugin.h"
28
29/**
30 * Disable 'save' button, dialog state is not acceptable.
31 *
32 * @param edc dialog to modify
33 */
34static void
35edit_dialog_disable_save (struct EditDialogContext *edc)
36{
37 gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (edc->builder,
38 "edit_dialog_save_button")),
39 FALSE);
40}
41
42
43/**
44 * Enable 'save' button, dialog state is acceptable.
45 *
46 * @param edc dialog to modify
47 */
48static void
49edit_dialog_enable_save (struct EditDialogContext *edc)
50{
51 gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (edc->builder,
52 "edit_dialog_save_button")),
53 TRUE);
54}
55
56
57/**
58 * Check that the common elements of the edit dialog are valid;
59 * if so, call 'edit_dialog_enable_save', otherwise 'edit_dialog_disable_save'.
60 *
61 * @param edc edit dialog to check
62 */
63static void
64edit_dialog_check_save (struct EditDialogContext *edc)
65{
66 GtkEditable *entry;
67 const gchar *name;
68
69 /* check name */
70 entry = GTK_EDITABLE (gtk_builder_get_object (edc->builder,
71 "edit_dialog_name_entry"));
72 name = gtk_editable_get_chars (entry, 0, -1);
73 if ( (GNUNET_SYSERR == GNUNET_DNSPARSER_check_label (name)) &&
74 (0 != strcmp (name, GNUNET_GNS_MASTERZONE_STR)) )
75 {
76 edit_dialog_disable_save (edc);
77 return;
78 }
79 /* any other checks should go here */
80 edit_dialog_enable_save (edc);
81}
82 28
83 29
84/** 30/**
85 * The 'relative' expiration time radiobutton was toggled (on or off). 31 * The 'relative' expiration time radiobutton was toggled (on or off).
86 * 32 *
87 * @param button the button 33 * @param button the button
88 * @param user_data the 'struct EditDialogContext' of the dialog 34 * @param user_data the '' of the dialog
89 */ 35 */
90void 36void
91GNS_edit_dialog_expiration_relative_radiobutton_toggled_cb (GtkToggleButton *button, 37GNS_edit_dialog_expiration_relative_radiobutton_toggled_cb (GtkToggleButton *button,
92 gpointer user_data) 38 gpointer user_data)
93{ 39{
94 struct EditDialogContext *edc = user_data; 40 struct GNUNET_GTK_NAMESTORE_PluginEnvironment *edc = user_data;
95 41
96 if (gtk_toggle_button_get_active (button)) 42 if (gtk_toggle_button_get_active (button))
97 gtk_widget_show (GTK_WIDGET (gtk_builder_get_object (edc->builder, 43 gtk_widget_show (GTK_WIDGET (gtk_builder_get_object (edc->builder,
@@ -106,7 +52,7 @@ GNS_edit_dialog_expiration_relative_radiobutton_toggled_cb (GtkToggleButton *but
106 * The 'forever' expiration time radiobutton was toggled (on or off). 52 * The 'forever' expiration time radiobutton was toggled (on or off).
107 * 53 *
108 * @param button the button 54 * @param button the button
109 * @param user_data the 'struct EditDialogContext' of the dialog 55 * @param user_data the '' of the dialog
110 */ 56 */
111void 57void
112GNS_edit_dialog_expiration_forever_radiobutton_toggled_cb (GtkToggleButton *button, 58GNS_edit_dialog_expiration_forever_radiobutton_toggled_cb (GtkToggleButton *button,
@@ -120,13 +66,13 @@ GNS_edit_dialog_expiration_forever_radiobutton_toggled_cb (GtkToggleButton *butt
120 * The 'absolute' expiration time radiobutton was toggled (on or off). 66 * The 'absolute' expiration time radiobutton was toggled (on or off).
121 * 67 *
122 * @param button the button 68 * @param button the button
123 * @param user_data the 'struct EditDialogContext' of the dialog 69 * @param user_data the '' of the dialog
124 */ 70 */
125void 71void
126GNS_edit_dialog_expiration_absolute_radiobutton_toggled_cb (GtkToggleButton *button, 72GNS_edit_dialog_expiration_absolute_radiobutton_toggled_cb (GtkToggleButton *button,
127 gpointer user_data) 73 gpointer user_data)
128{ 74{
129 struct EditDialogContext *edc = user_data; 75 struct GNUNET_GTK_NAMESTORE_PluginEnvironment *edc = user_data;
130 76
131 if (gtk_toggle_button_get_active (button)) 77 if (gtk_toggle_button_get_active (button))
132 { 78 {
@@ -145,1900 +91,5 @@ GNS_edit_dialog_expiration_absolute_radiobutton_toggled_cb (GtkToggleButton *but
145} 91}
146 92
147 93
148/**
149 * Setup the zone combobox.
150 *
151 * @param edc dialog to setup the combo box for
152 */
153static void
154setup_zone (struct EditDialogContext *edc)
155{
156 GtkTreeIter iter;
157 GtkComboBox *cb;
158 gchar *name;
159
160 cb = GTK_COMBO_BOX (gtk_builder_get_object (edc->builder,
161 "edit_dialog_zone_combobox"));
162
163 gtk_combo_box_set_model (cb,
164 GTK_TREE_MODEL (edc->zone_liststore));
165 GNUNET_assert (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (edc->zone_liststore),
166 &iter));
167 do {
168 gtk_tree_model_get (GTK_TREE_MODEL (edc->zone_liststore),
169 &iter,
170 ZONE_LS_NAME, &name,
171 -1);
172 if (0 == strcmp (name,
173 edc->new_zone_option))
174 {
175 g_free (name);
176 break;
177 }
178 g_free (name);
179 } while (gtk_tree_model_iter_next (GTK_TREE_MODEL (edc->zone_liststore),
180 &iter));
181 gtk_combo_box_set_active_iter (cb,
182 &iter);
183}
184
185
186/**
187 * Initialize widgets of the edit dialog that are the same regardless of
188 * the type of the record.
189 *
190 * @param edc dialog context
191 */
192static void
193edit_dialog_setup_common_elements (struct EditDialogContext *edc)
194{
195 GtkComboBox *cb;
196 GtkListStore *ls;
197 GtkTreeIter iter;
198 struct GNUNET_TIME_Absolute at;
199 struct GNUNET_TIME_Relative rt;
200 time_t tp;
201 struct tm *ymd;
202 GtkCalendar *cal;
203
204 if (GNUNET_YES !=
205 edc->old_record_in_namestore)
206 {
207 gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (edc->builder,
208 "edit_dialog_delete_button")));
209 edit_dialog_disable_save (edc);
210 }
211 gtk_entry_set_text (GTK_ENTRY (gtk_builder_get_object (edc->builder,
212 "edit_dialog_name_entry")),
213 edc->name);
214 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (edc->builder,
215 "edit_dialog_options_public_checkbutton")),
216 edc->n_public);
217 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (edc->builder,
218 "edit_dialog_options_shadow_checkbutton")),
219 edc->n_is_shadow);
220 if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us == edc->n_exp_time)
221 {
222 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (edc->builder,
223 "edit_dialog_expiration_never_radiobutton")),
224 TRUE);
225 gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (edc->builder,
226 "edit_dialog_expiration_absolute_calendar")));
227 gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (edc->builder,
228 "edit_dialog_expiration_absolute_hbox")));
229 gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (edc->builder,
230 "edit_dialog_expiration_relative_combobox")));
231 }
232 if ( (edc->n_is_relative) &&
233 (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != edc->n_exp_time) )
234 {
235 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (edc->builder,
236 "edit_dialog_expiration_relative_radiobutton")),
237 TRUE);
238 gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (edc->builder,
239 "edit_dialog_expiration_absolute_calendar")));
240 gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (edc->builder,
241 "edit_dialog_expiration_absolute_hbox")));
242 rt.rel_value_us = edc->n_exp_time;
243 }
244 else
245 {
246 /* select a sane default */
247 rt = GNUNET_TIME_UNIT_DAYS;
248 }
249 cb = GTK_COMBO_BOX (gtk_builder_get_object (edc->builder,
250 "edit_dialog_expiration_relative_combobox"));
251 ls = GTK_LIST_STORE (gtk_combo_box_get_model (cb));
252 gtk_list_store_insert_with_values (ls, &iter,
253 -1 /* position: append */,
254 0, GNUNET_STRINGS_relative_time_to_string (rt, GNUNET_NO),
255 -1);
256 gtk_combo_box_set_active_iter (cb, &iter);
257 if ( (! edc->n_is_relative) &&
258 (GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us != edc->n_exp_time) )
259 {
260 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (edc->builder,
261 "edit_dialog_expiration_absolute_radiobutton")),
262 TRUE);
263
264 gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (edc->builder,
265 "edit_dialog_expiration_relative_combobox")));
266 at.abs_value_us = edc->n_exp_time;
267 }
268 else
269 {
270 /* select a sane default: right now */
271 at = GNUNET_TIME_absolute_get ();
272 }
273 tp = (time_t) (at.abs_value_us / 1000000LL); /* convert to seconds */
274 ymd = gmtime (&tp);
275 cal = GTK_CALENDAR (gtk_builder_get_object (edc->builder,
276 "edit_dialog_expiration_absolute_calendar"));
277 gtk_calendar_select_month (cal,
278 ymd->tm_mon,
279 ymd->tm_year + 1900);
280 gtk_calendar_mark_day (cal,
281 ymd->tm_mday);
282 gtk_spin_button_set_value (GTK_SPIN_BUTTON (gtk_builder_get_object (edc->builder,
283 "edit_dialog_expiration_absolute_hours_spinbutton")),
284 (double) ymd->tm_hour);
285 gtk_spin_button_set_value (GTK_SPIN_BUTTON (gtk_builder_get_object (edc->builder,
286 "edit_dialog_expiration_absolute_minutes_spinbutton")),
287 (double) ymd->tm_min);
288 gtk_spin_button_set_value (GTK_SPIN_BUTTON (gtk_builder_get_object (edc->builder,
289 "edit_dialog_expiration_absolute_seconds_spinbutton")),
290 (double) ymd->tm_sec);
291 setup_zone (edc);
292}
293
294
295/**
296 * Perform the reverse of the 'edit_dialog_setup_common_elements' function,
297 * that is, extract the values from the (common) widgets and store the
298 * values in 'edc'.
299 *
300 * @param edc edit dialog to extract data from
301 */
302static void
303edit_dialog_putes_common_elements (struct EditDialogContext *edc)
304{
305 const char *rt_s;
306 struct GNUNET_TIME_Relative rt;
307 GtkComboBox *cb;
308 GtkTreeModel *tm;
309 GtkTreeIter iter;
310 gchar *opt;
311 struct GNUNET_IDENTITY_Ego *ego;
312
313 /* is public flag */
314 edc->n_public = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (edc->builder,
315 "edit_dialog_options_public_checkbutton")));
316 /* is shadow flag */
317 edc->n_is_shadow = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (edc->builder,
318 "edit_dialog_options_shadow_checkbutton")));
319
320 /* 'forever' expiration time */
321 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (edc->builder,
322 "edit_dialog_expiration_never_radiobutton"))))
323 {
324 edc->n_exp_time = GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us;
325 edc->n_is_relative = TRUE; /* doesn't matter, but make sure it is well-defined anyway */
326 }
327
328 /* 'relative' expiration time */
329 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (edc->builder,
330 "edit_dialog_expiration_relative_radiobutton"))))
331 {
332 cb = GTK_COMBO_BOX (gtk_builder_get_object (edc->builder,
333 "edit_dialog_expiration_relative_combobox"));
334 tm = gtk_combo_box_get_model (cb);
335 if (! gtk_combo_box_get_active_iter (cb, &iter))
336 {
337 GNUNET_break (0);
338 return;
339 }
340 gtk_tree_model_get (tm, &iter,
341 0, &rt_s,
342 -1);
343 GNUNET_break (GNUNET_YES ==
344 GNUNET_STRINGS_fancy_time_to_relative (rt_s,
345 &rt));
346 edc->n_exp_time = rt.rel_value_us;
347 edc->n_is_relative = TRUE;
348 }
349
350 /* 'absolute' expiration time */
351 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (edc->builder,
352 "edit_dialog_expiration_absolute_radiobutton"))))
353 {
354 guint year;
355 guint month;
356 guint day;
357 guint hour;
358 guint minute;
359 guint second;
360 char fancydate[128];
361 struct GNUNET_TIME_Absolute atime;
362
363 gtk_calendar_get_date (GTK_CALENDAR (gtk_builder_get_object (edc->builder,
364 "edit_dialog_expiration_absolute_calendar")),
365 &year, &month, &day);
366 hour = gtk_spin_button_get_value (GTK_SPIN_BUTTON (gtk_builder_get_object (edc->builder,
367 "edit_dialog_expiration_absolute_hours_spinbutton")));
368 minute = gtk_spin_button_get_value (GTK_SPIN_BUTTON (gtk_builder_get_object (edc->builder,
369 "edit_dialog_expiration_absolute_minutes_spinbutton")));
370 second = gtk_spin_button_get_value (GTK_SPIN_BUTTON (gtk_builder_get_object (edc->builder,
371 "edit_dialog_expiration_absolute_seconds_spinbutton")));
372 GNUNET_snprintf (fancydate,
373 sizeof (fancydate),
374 "%u-%u-%u %u:%u:%u",
375 (unsigned int) year,
376 (unsigned int) month + 1,
377 (unsigned int) day,
378 (unsigned int) hour,
379 (unsigned int) minute,
380 (unsigned int) second);
381 GNUNET_break (GNUNET_OK ==
382 GNUNET_STRINGS_fancy_time_to_absolute (fancydate,
383 &atime));
384 edc->n_exp_time = atime.abs_value_us;
385 edc->n_is_relative = FALSE;
386 }
387
388 /* extract target zone! */
389 cb = GTK_COMBO_BOX (gtk_builder_get_object (edc->builder,
390 "edit_dialog_zone_combobox"));
391 tm = gtk_combo_box_get_model (cb);
392 if (! gtk_combo_box_get_active_iter (cb, &iter))
393 {
394 GNUNET_break (0);
395 }
396 else
397 {
398 gtk_tree_model_get (tm, &iter,
399 ZONE_LS_NAME, &opt,
400 ZONE_LS_EGO, &ego,
401 -1);
402 if (NULL == opt)
403 {
404 GNUNET_break (0);
405 }
406 else
407 {
408 g_free (edc->new_zone_option);
409 edc->new_zone_option = g_strdup (opt);
410 g_free (opt);
411 edc->ego = ego;
412 }
413 }
414}
415
416
417/**
418 * Run the edit dialog. Performs all of the common initialization
419 * steps to run an edit dialog for records.
420 *
421 * @param edc editing context
422 */
423static void
424run_edit_dialog (struct EditDialogContext *edc)
425{
426 edit_dialog_setup_common_elements (edc);
427 gtk_dialog_set_default_response (edc->dialog,
428 GTK_RESPONSE_OK);
429 gtk_window_present (GTK_WINDOW (edc->dialog));
430}
431
432
433/* ************************ A records *********************** */
434
435/**
436 * Check validity of the value in the edit dialog for A-records.
437 * Then call the shared validity check if the result is OK.
438 *
439 * @param edc edit dialog context
440 */
441static void
442edit_dialog_a_validity_check (struct EditDialogContext *edc)
443{
444 GtkEditable *entry;
445 const gchar *preedit;
446 struct in_addr v4;
447
448 entry = GTK_EDITABLE (gtk_builder_get_object (edc->builder,
449 "edit_dialog_a_entry")),
450 preedit = gtk_editable_get_chars (entry, 0, -1);
451 if ( (NULL == preedit) ||
452 (1 != inet_pton (AF_INET, preedit, &v4)) )
453 {
454 edit_dialog_disable_save (edc);
455 return;
456 }
457 edit_dialog_check_save (edc);
458}
459
460
461/**
462 * Editing dialog was closed, get the data and call the
463 * continuation.
464 *
465 * @param dialog editing dialog
466 * @param response_id action that caused the dialog to be closed
467 * @param user_data the 'struct EditDialogContext'
468 */
469void
470GNS_edit_a_dialog_response_cb (GtkDialog *dialog,
471 gint response_id,
472 gpointer user_data)
473{
474 struct EditDialogContext *edc = user_data;
475 GtkEntry *entry;
476 const gchar *value;
477
478 if (GTK_RESPONSE_OK == response_id)
479 {
480 edit_dialog_putes_common_elements (edc);
481 entry = GTK_ENTRY (gtk_builder_get_object (edc->builder,
482 "edit_dialog_a_entry"));
483 value = gtk_entry_get_text (entry);
484 g_free (edc->n_value);
485 edc->n_value = g_strdup (value);
486 }
487 gtk_widget_destroy (GTK_WIDGET (edc->dialog));
488 g_object_unref (edc->builder);
489 edc->builder = NULL;
490 edc->cont (edc, response_id);
491}
492
493
494/**
495 * The user has edited the A record value. Enable/disable 'save'
496 * button depending on the validity of the value.
497 *
498 * @param entry editing widget
499 * @param user_data the 'struct EditDialogContext' of the dialog
500 */
501void
502GNS_edit_dialog_a_entry_changed_cb (GtkEditable *entry,
503 gpointer user_data)
504{
505 struct EditDialogContext *edc = user_data;
506
507 edit_dialog_a_validity_check (edc);
508}
509
510
511/**
512 * Run an GNS Edit dialog for an 'A' Record.
513 *
514 * @param edc editing context to use
515 */
516void
517GNS_edit_dialog_a (struct EditDialogContext *edc)
518{
519 edc->builder = GNUNET_GTK_get_new_builder ("gnunet_namestore_edit_a.glade",
520 edc);
521 if (NULL == edc->builder)
522 {
523 GNUNET_break (0);
524 edc->cont (edc, GTK_RESPONSE_CANCEL); /* treat as 'cancel' */
525 return;
526 }
527 if (GNUNET_YES ==
528 edc->old_record_in_namestore)
529 {
530 /* set A record */
531 gtk_entry_set_text (GTK_ENTRY (gtk_builder_get_object (edc->builder,
532 "edit_dialog_a_entry")),
533 edc->n_value);
534 }
535 edc->validator = &edit_dialog_a_validity_check;
536 edc->dialog = GTK_DIALOG (gtk_builder_get_object (edc->builder,
537 "edit_a_dialog"));
538 run_edit_dialog (edc);
539}
540
541
542/* ************************ AAAA records *********************** */
543
544/**
545 * Check validity of the value in the edit dialog for AAAA-records.
546 * Then call the shared validity check if the result is OK.
547 *
548 * @param edc edit dialog context
549 */
550static void
551edit_dialog_aaaa_validity_check (struct EditDialogContext *edc)
552{
553 GtkEditable *entry;
554 const gchar *preedit;
555 struct in6_addr v6;
556
557 entry = GTK_EDITABLE (gtk_builder_get_object (edc->builder,
558 "edit_dialog_aaaa_entry")),
559 preedit = gtk_editable_get_chars (entry, 0, -1);
560 if ( (NULL == preedit) ||
561 (1 != inet_pton (AF_INET6, preedit, &v6)) )
562 {
563 edit_dialog_disable_save (edc);
564 return;
565 }
566 edit_dialog_check_save (edc);
567}
568
569
570/**
571 * Editing dialog was closed, get the data and call the
572 * continuation.
573 *
574 * @param dialog editing dialog
575 * @param response_id action that caused the dialog to be closed
576 * @param user_data the 'struct EditDialogContext'
577 */
578void
579GNS_edit_aaaa_dialog_response_cb (GtkDialog *dialog,
580 gint response_id,
581 gpointer user_data)
582{
583 struct EditDialogContext *edc = user_data;
584 GtkEntry *entry;
585 const gchar *value;
586
587 if (GTK_RESPONSE_OK == response_id)
588 {
589 edit_dialog_putes_common_elements (edc);
590 entry = GTK_ENTRY (gtk_builder_get_object (edc->builder,
591 "edit_dialog_aaaa_entry"));
592 value = gtk_entry_get_text (entry);
593 g_free (edc->n_value);
594 edc->n_value = g_strdup (value);
595 }
596 gtk_widget_destroy (GTK_WIDGET (edc->dialog));
597 g_object_unref (edc->builder);
598 edc->builder = NULL;
599 edc->cont (edc, response_id);
600}
601
602
603/**
604 * The user has edited the AAAA record value. Enable/disable 'save'
605 * button depending on the validity of the value.
606 *
607 * @param entry editing widget
608 * @param user_data the 'struct EditDialogContext' of the dialog
609 */
610void
611GNS_edit_dialog_aaaa_entry_changed_cb (GtkEditable *entry,
612 gpointer user_data)
613{
614 struct EditDialogContext *edc = user_data;
615
616 edit_dialog_aaaa_validity_check (edc);
617}
618
619
620/**
621 * Run an GNS Edit dialog for an 'AAAA' Record.
622 *
623 * @param edc editing context to use
624 */
625void
626GNS_edit_dialog_aaaa (struct EditDialogContext *edc)
627{
628 edc->builder = GNUNET_GTK_get_new_builder ("gnunet_namestore_edit_aaaa.glade",
629 edc);
630 if (NULL == edc->builder)
631 {
632 GNUNET_break (0);
633 edc->cont (edc, GTK_RESPONSE_CANCEL); /* treat as 'cancel' */
634 return;
635 }
636 if (GNUNET_YES ==
637 edc->old_record_in_namestore)
638 {
639 /* set AAAA record */
640 gtk_entry_set_text (GTK_ENTRY (gtk_builder_get_object (edc->builder,
641 "edit_dialog_aaaa_entry")),
642 edc->n_value);
643 }
644 edc->validator = &edit_dialog_aaaa_validity_check;
645 edc->dialog = GTK_DIALOG (gtk_builder_get_object (edc->builder,
646 "edit_aaaa_dialog"));
647 run_edit_dialog (edc);
648}
649
650
651/* ************************ CNAME records *********************** */
652
653/**
654 * Check validity of the value in the edit dialog for AAAA-records.
655 * Then call the shared validity check if the result is OK.
656 *
657 * @param edc edit dialog context
658 */
659static void
660edit_dialog_cname_validity_check (struct EditDialogContext *edc)
661{
662 GtkEditable *entry;
663 const gchar *preedit;
664
665 entry = GTK_EDITABLE (gtk_builder_get_object (edc->builder,
666 "edit_dialog_cname_entry")),
667 preedit = gtk_editable_get_chars (entry, 0, -1);
668 if ( (NULL == preedit) ||
669 (GNUNET_OK != GNUNET_DNSPARSER_check_name (preedit)) )
670 {
671 edit_dialog_disable_save (edc);
672 return;
673 }
674 edit_dialog_check_save (edc);
675}
676
677
678/**
679 * Editing dialog was closed, get the data and call the
680 * continuation.
681 *
682 * @param dialog editing dialog
683 * @param response_id action that caused the dialog to be closed
684 * @param user_data the 'struct EditDialogContext'
685 */
686void
687GNS_edit_cname_dialog_response_cb (GtkDialog *dialog,
688 gint response_id,
689 gpointer user_data)
690{
691 struct EditDialogContext *edc = user_data;
692 GtkEntry *entry;
693 const gchar *value;
694
695 if (GTK_RESPONSE_OK == response_id)
696 {
697 edit_dialog_putes_common_elements (edc);
698 entry = GTK_ENTRY (gtk_builder_get_object (edc->builder,
699 "edit_dialog_cname_entry"));
700 value = gtk_entry_get_text (entry);
701 g_free (edc->n_value);
702 edc->n_value = g_strdup (value);
703 }
704 gtk_widget_destroy (GTK_WIDGET (edc->dialog));
705 g_object_unref (edc->builder);
706 edc->builder = NULL;
707 edc->cont (edc, response_id);
708}
709
710
711/**
712 * The user has edited the CNAME record value. Enable/disable 'save'
713 * button depending on the validity of the value.
714 *
715 * @param entry editing widget
716 * @param user_data the 'struct EditDialogContext' of the dialog
717 */
718void
719GNS_edit_dialog_cname_entry_changed_cb (GtkEditable *entry,
720 gpointer user_data)
721{
722 struct EditDialogContext *edc = user_data;
723
724 edit_dialog_cname_validity_check (edc);
725}
726
727
728/**
729 * Run an GNS Edit dialog for an 'CNAME' Record.
730 *
731 * @param edc editing context to use
732 */
733void
734GNS_edit_dialog_cname (struct EditDialogContext *edc)
735{
736 edc->builder = GNUNET_GTK_get_new_builder ("gnunet_namestore_edit_cname.glade",
737 edc);
738 if (NULL == edc->builder)
739 {
740 GNUNET_break (0);
741 edc->cont (edc, GTK_RESPONSE_CANCEL); /* treat as 'cancel' */
742 return;
743 }
744 if (GNUNET_YES ==
745 edc->old_record_in_namestore)
746 {
747 /* set CNAME record */
748 gtk_entry_set_text (GTK_ENTRY (gtk_builder_get_object (edc->builder,
749 "edit_dialog_cname_entry")),
750 edc->n_value);
751 }
752 edc->validator = &edit_dialog_cname_validity_check;
753 edc->dialog = GTK_DIALOG (gtk_builder_get_object (edc->builder,
754 "edit_cname_dialog"));
755 run_edit_dialog (edc);
756}
757
758
759/* ************************ LEHO records *********************** */
760
761/**
762 * Check validity of the value in the edit dialog for LEHO-records.
763 * Then call the shared validity check if the result is OK.
764 *
765 * @param edc edit dialog context
766 */
767static void
768edit_dialog_leho_validity_check (struct EditDialogContext *edc)
769{
770 GtkEditable *entry;
771 const gchar *preedit;
772
773 entry = GTK_EDITABLE (gtk_builder_get_object (edc->builder,
774 "edit_dialog_leho_entry")),
775 preedit = gtk_editable_get_chars (entry, 0, -1);
776 if ( (NULL == preedit) ||
777 (GNUNET_OK != GNUNET_DNSPARSER_check_name (preedit)) )
778 {
779 edit_dialog_disable_save (edc);
780 return;
781 }
782 edit_dialog_check_save (edc);
783}
784
785
786/**
787 * Editing dialog was closed, get the data and call the
788 * continuation.
789 *
790 * @param dialog editing dialog
791 * @param response_id action that caused the dialog to be closed
792 * @param user_data the 'struct EditDialogContext'
793 */
794void
795GNS_edit_leho_dialog_response_cb (GtkDialog *dialog,
796 gint response_id,
797 gpointer user_data)
798{
799 struct EditDialogContext *edc = user_data;
800 GtkEntry *entry;
801 const gchar *value;
802
803 if (GTK_RESPONSE_OK == response_id)
804 {
805 edit_dialog_putes_common_elements (edc);
806 entry = GTK_ENTRY (gtk_builder_get_object (edc->builder,
807 "edit_dialog_leho_entry"));
808 value = gtk_entry_get_text (entry);
809 g_free (edc->n_value);
810 edc->n_value = g_strdup (value);
811 }
812 gtk_widget_destroy (GTK_WIDGET (edc->dialog));
813 g_object_unref (edc->builder);
814 edc->builder = NULL;
815 edc->cont (edc, response_id);
816}
817
818
819/**
820 * The user has edited the LEHO record value. Enable/disable 'save'
821 * button depending on the validity of the value.
822 *
823 * @param entry editing widget
824 * @param user_data the 'struct EditDialogContext' of the dialog
825 */
826void
827GNS_edit_dialog_leho_entry_changed_cb (GtkEditable *entry,
828 gpointer user_data)
829{
830 struct EditDialogContext *edc = user_data;
831
832 edit_dialog_leho_validity_check (edc);
833}
834
835
836/**
837 * Run an GNS Edit dialog for an 'LEHO' Record.
838 *
839 * @param edc editing context to use
840 */
841void
842GNS_edit_dialog_leho (struct EditDialogContext *edc)
843{
844 edc->builder = GNUNET_GTK_get_new_builder ("gnunet_namestore_edit_leho.glade",
845 edc);
846 if (NULL == edc->builder)
847 {
848 GNUNET_break (0);
849 edc->cont (edc, GTK_RESPONSE_CANCEL); /* treat as 'cancel' */
850 return;
851 }
852 if (GNUNET_YES ==
853 edc->old_record_in_namestore)
854 {
855 /* set LEHO record */
856 gtk_entry_set_text (GTK_ENTRY (gtk_builder_get_object (edc->builder,
857 "edit_dialog_leho_entry")),
858 edc->n_value);
859 }
860 edc->validator = &edit_dialog_leho_validity_check;
861 edc->dialog = GTK_DIALOG (gtk_builder_get_object (edc->builder,
862 "edit_leho_dialog"));
863 run_edit_dialog (edc);
864}
865
866
867/* ************************ MX records *********************** */
868
869/**
870 * Check validity of the value in the edit dialog for MX-records.
871 * Then call the shared validity check if the result is OK.
872 *
873 * @param edc edit dialog context
874 */
875static void
876edit_dialog_mx_validity_check (struct EditDialogContext *edc)
877{
878 GtkEditable *entry;
879 const gchar *preedit;
880
881 entry = GTK_EDITABLE (gtk_builder_get_object (edc->builder,
882 "edit_dialog_mx_entry")),
883 preedit = gtk_editable_get_chars (entry, 0, -1);
884 if ( (NULL == preedit) ||
885 (GNUNET_OK != GNUNET_DNSPARSER_check_name (preedit)) )
886 {
887 edit_dialog_disable_save (edc);
888 return;
889 }
890 edit_dialog_check_save (edc);
891}
892
893
894/**
895 * Editing dialog was closed, get the data and call the
896 * continuation.
897 *
898 * @param dialog editing dialog
899 * @param response_id action that caused the dialog to be closed
900 * @param user_data the 'struct EditDialogContext'
901 */
902void
903GNS_edit_mx_dialog_response_cb (GtkDialog *dialog,
904 gint response_id,
905 gpointer user_data)
906{
907 struct EditDialogContext *edc = user_data;
908 GtkEntry *entry;
909 const gchar *value;
910 char *result;
911 unsigned int distance;
912
913 if (GTK_RESPONSE_OK == response_id)
914 {
915 edit_dialog_putes_common_elements (edc);
916 entry = GTK_ENTRY (gtk_builder_get_object (edc->builder,
917 "edit_dialog_mx_entry"));
918 value = gtk_entry_get_text (entry);
919 distance = gtk_spin_button_get_value (GTK_SPIN_BUTTON (gtk_builder_get_object (edc->builder,
920 "edit_dialog_mx_distance_spinbutton")));
921 g_free (edc->n_value);
922 GNUNET_asprintf (&result,
923 "%hu,%s",
924 distance,
925 value);
926 edc->n_value = g_strdup (result);
927 GNUNET_free (result);
928 }
929 gtk_widget_destroy (GTK_WIDGET (edc->dialog));
930 g_object_unref (edc->builder);
931 edc->builder = NULL;
932 edc->cont (edc, response_id);
933}
934
935
936/**
937 * The user has edited the MX record value. Enable/disable 'save'
938 * button depending on the validity of the value.
939 *
940 * @param entry editing widget
941 * @param user_data the 'struct EditDialogContext' of the dialog
942 */
943void
944GNS_edit_dialog_mx_entry_changed_cb (GtkEditable *entry,
945 gpointer user_data)
946{
947 struct EditDialogContext *edc = user_data;
948
949 edit_dialog_mx_validity_check (edc);
950}
951
952
953/**
954 * Run an GNS Edit dialog for an 'MX' Record.
955 *
956 * @param edc editing context to use
957 */
958void
959GNS_edit_dialog_mx (struct EditDialogContext *edc)
960{
961 uint16_t mx_pref;
962 char result[253 + 1];
963
964 edc->builder = GNUNET_GTK_get_new_builder ("gnunet_namestore_edit_mx.glade",
965 edc);
966 if (NULL == edc->builder)
967 {
968 GNUNET_break (0);
969 edc->cont (edc, GTK_RESPONSE_CANCEL); /* treat as 'cancel' */
970 return;
971 }
972 if (GNUNET_YES ==
973 edc->old_record_in_namestore)
974 {
975 if (2 != SSCANF(edc->n_value,
976 "%hu,%253s", &mx_pref, result))
977 {
978 GNUNET_break (0);
979 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
980 _("Unable to parse MX record `%s'\n"),
981 edc->n_value);
982 }
983 else
984 {
985 gtk_entry_set_text (GTK_ENTRY (gtk_builder_get_object (edc->builder,
986 "edit_dialog_mx_entry")),
987 result);
988 gtk_spin_button_set_value (GTK_SPIN_BUTTON (gtk_builder_get_object (edc->builder,
989 "edit_dialog_mx_distance_spinbutton")),
990 mx_pref);
991 }
992 }
993 edc->validator = &edit_dialog_mx_validity_check;
994 edc->dialog = GTK_DIALOG (gtk_builder_get_object (edc->builder,
995 "edit_mx_dialog"));
996 run_edit_dialog (edc);
997}
998
999
1000/* ************************ GNS2DNS records *********************** */
1001
1002/**
1003 * Check validity of the value in the edit dialog for GNS2DNS-records.
1004 * Then call the shared validity check if the result is OK.
1005 *
1006 * @param edc edit dialog context
1007 */
1008static void
1009edit_dialog_gns2dns_validity_check (struct EditDialogContext *edc)
1010{
1011 GtkEditable *entry;
1012 const gchar *preedit;
1013
1014 entry = GTK_EDITABLE (gtk_builder_get_object (edc->builder,
1015 "edit_dialog_gns2dns_entry")),
1016 preedit = gtk_editable_get_chars (entry, 0, -1);
1017 if ( (NULL == preedit) ||
1018 (GNUNET_OK != GNUNET_DNSPARSER_check_name (preedit)) )
1019 {
1020 edit_dialog_disable_save (edc);
1021 return;
1022 }
1023 edit_dialog_check_save (edc);
1024}
1025
1026
1027/**
1028 * Editing dialog was closed, get the data and call the
1029 * continuation.
1030 *
1031 * @param dialog editing dialog
1032 * @param response_id action that caused the dialog to be closed
1033 * @param user_data the 'struct EditDialogContext'
1034 */
1035void
1036GNS_edit_gns2dns_dialog_response_cb (GtkDialog *dialog,
1037 gint response_id,
1038 gpointer user_data)
1039{
1040 struct EditDialogContext *edc = user_data;
1041 GtkEntry *entry;
1042 const gchar *value;
1043
1044 if (GTK_RESPONSE_OK == response_id)
1045 {
1046 edit_dialog_putes_common_elements (edc);
1047 entry = GTK_ENTRY (gtk_builder_get_object (edc->builder,
1048 "edit_dialog_gns2dns_entry"));
1049 value = gtk_entry_get_text (entry);
1050 g_free (edc->n_value);
1051 edc->n_value = g_strdup (value);
1052 }
1053 gtk_widget_destroy (GTK_WIDGET (edc->dialog));
1054 g_object_unref (edc->builder);
1055 edc->builder = NULL;
1056 edc->cont (edc, response_id);
1057}
1058
1059
1060/**
1061 * The user has edited the GNS2DNS record value. Enable/disable 'save'
1062 * button depending on the validity of the value.
1063 *
1064 * @param entry editing widget
1065 * @param user_data the 'struct EditDialogContext' of the dialog
1066 */
1067void
1068GNS_edit_dialog_gns2dns_entry_changed_cb (GtkEditable *entry,
1069 gpointer user_data)
1070{
1071 struct EditDialogContext *edc = user_data;
1072
1073 edit_dialog_gns2dns_validity_check (edc);
1074}
1075
1076
1077/**
1078 * Run an GNS Edit dialog for a 'GNS2DNS' Record.
1079 *
1080 * @param edc editing context to use
1081 */
1082void
1083GNS_edit_dialog_gns2dns (struct EditDialogContext *edc)
1084{
1085 edc->builder = GNUNET_GTK_get_new_builder ("gnunet_namestore_edit_gns2dns.glade",
1086 edc);
1087 if (NULL == edc->builder)
1088 {
1089 GNUNET_break (0);
1090 edc->cont (edc, GTK_RESPONSE_CANCEL); /* treat as 'cancel' */
1091 return;
1092 }
1093 if (GNUNET_YES ==
1094 edc->old_record_in_namestore)
1095 {
1096 /* set NS record */
1097 gtk_entry_set_text (GTK_ENTRY (gtk_builder_get_object (edc->builder,
1098 "edit_dialog_gns2dns_entry")),
1099 edc->n_value);
1100 }
1101 edc->validator = &edit_dialog_gns2dns_validity_check;
1102 edc->dialog = GTK_DIALOG (gtk_builder_get_object (edc->builder,
1103 "edit_gns2dns_dialog"));
1104 run_edit_dialog (edc);
1105}
1106
1107
1108/* ************************ PHONE records *********************** */
1109
1110/**
1111 * Check validity of the value in the edit dialog for PHONE-records.
1112 * Then call the shared validity check if the result is OK.
1113 *
1114 * @param edc edit dialog context
1115 */
1116static void
1117edit_dialog_phone_validity_check (struct EditDialogContext *edc)
1118{
1119 GtkEditable *entry;
1120 const gchar *preedit;
1121 struct GNUNET_CRYPTO_EcdsaPublicKey pub;
1122
1123 entry = GTK_EDITABLE (gtk_builder_get_object (edc->builder,
1124 "edit_dialog_phone_peer_entry"));
1125 preedit = gtk_editable_get_chars (entry, 0, -1);
1126 if ( (NULL == preedit) ||
1127 (GNUNET_OK !=
1128 GNUNET_CRYPTO_ecdsa_public_key_from_string (preedit,
1129 strlen (preedit),
1130 &pub)) )
1131 {
1132 edit_dialog_disable_save (edc);
1133 return;
1134 }
1135 edit_dialog_check_save (edc);
1136}
1137
1138
1139/**
1140 * Editing dialog was closed, get the data and call the
1141 * continuation.
1142 *
1143 * @param dialog editing dialog
1144 * @param response_id action that caused the dialog to be closed
1145 * @param user_data the 'struct EditDialogContext'
1146 */
1147void
1148GNS_edit_phone_dialog_response_cb (GtkDialog *dialog,
1149 gint response_id,
1150 gpointer user_data)
1151{
1152 struct EditDialogContext *edc = user_data;
1153 GtkEntry *entry;
1154 GtkSpinButton *spin;
1155 const gchar *value;
1156 unsigned int line;
1157
1158 if (GTK_RESPONSE_OK == response_id)
1159 {
1160 edit_dialog_putes_common_elements (edc);
1161 entry = GTK_ENTRY (gtk_builder_get_object (edc->builder,
1162 "edit_dialog_phone_peer_entry"));
1163 value = gtk_entry_get_text (entry);
1164 spin = GTK_SPIN_BUTTON (gtk_builder_get_object (edc->builder,
1165 "edit_dialog_phone_line_spinbutton"));
1166 line = gtk_spin_button_get_value (spin);
1167 g_free (edc->n_value);
1168 GNUNET_asprintf (&edc->n_value,
1169 "%u-%s",
1170 line,
1171 value);
1172 }
1173 gtk_widget_destroy (GTK_WIDGET (edc->dialog));
1174 g_object_unref (edc->builder);
1175 edc->builder = NULL;
1176 edc->cont (edc, response_id);
1177}
1178
1179
1180/**
1181 * The user has edited the PHONE record value. Enable/disable 'save'
1182 * button depending on the validity of the value.
1183 *
1184 * @param entry editing widget
1185 * @param user_data the 'struct EditDialogContext' of the dialog
1186 */
1187void
1188GNS_edit_dialog_phone_peer_entry_changed_cb (GtkEditable *entry,
1189 gpointer user_data)
1190{
1191 struct EditDialogContext *edc = user_data;
1192
1193 edit_dialog_phone_validity_check (edc);
1194}
1195
1196
1197/**
1198 * Run an GNS Edit dialog for a 'PHONE' Record.
1199 *
1200 * @param edc editing context to use
1201 */
1202void
1203GNS_edit_dialog_phone (struct EditDialogContext *edc)
1204{
1205 const char *minus;
1206 unsigned int line;
1207
1208 edc->builder = GNUNET_GTK_get_new_builder ("gnunet_namestore_edit_phone.glade",
1209 edc);
1210 if (NULL == edc->builder)
1211 {
1212 GNUNET_break (0);
1213 edc->cont (edc, GTK_RESPONSE_CANCEL); /* treat as 'cancel' */
1214 return;
1215 }
1216 if (GNUNET_YES ==
1217 edc->old_record_in_namestore)
1218 {
1219 /* set PKEY record */
1220 if (1 != (sscanf (edc->n_value,
1221 "%u-",
1222 &line)))
1223 {
1224 GNUNET_break (0);
1225 }
1226 else
1227 {
1228 gtk_spin_button_set_value (GTK_SPIN_BUTTON (gtk_builder_get_object (edc->builder,
1229 "edit_dialog_phone_line_spinbutton")),
1230 line);
1231
1232 }
1233 if (NULL == (minus = strchr (edc->n_value, '-')))
1234 {
1235 GNUNET_break (0);
1236 }
1237 else
1238 {
1239 gtk_entry_set_text (GTK_ENTRY (gtk_builder_get_object (edc->builder,
1240 "edit_dialog_phone_peer_entry")),
1241 minus + 1);
1242 }
1243 }
1244 edc->validator = &edit_dialog_phone_validity_check;
1245 edc->dialog = GTK_DIALOG (gtk_builder_get_object (edc->builder,
1246 "edit_phone_dialog"));
1247 run_edit_dialog (edc);
1248}
1249
1250
1251/* ************************ PKEY records *********************** */
1252
1253/**
1254 * Check validity of the value in the edit dialog for PKEY-records.
1255 * Then call the shared validity check if the result is OK.
1256 *
1257 * @param edc edit dialog context
1258 */
1259static void
1260edit_dialog_pkey_validity_check (struct EditDialogContext *edc)
1261{
1262 GtkEditable *entry;
1263 const gchar *preedit;
1264 struct GNUNET_CRYPTO_EcdsaPublicKey pub;
1265
1266 entry = GTK_EDITABLE (gtk_builder_get_object (edc->builder,
1267 "edit_dialog_pkey_entry")),
1268 preedit = gtk_editable_get_chars (entry, 0, -1);
1269 if ( (NULL == preedit) ||
1270 (GNUNET_OK !=
1271 GNUNET_CRYPTO_ecdsa_public_key_from_string (preedit,
1272 strlen (preedit),
1273 &pub)) )
1274 {
1275 edit_dialog_disable_save (edc);
1276 return;
1277 }
1278 edit_dialog_check_save (edc);
1279}
1280
1281
1282/**
1283 * Editing dialog was closed, get the data and call the
1284 * continuation.
1285 *
1286 * @param dialog editing dialog
1287 * @param response_id action that caused the dialog to be closed
1288 * @param user_data the 'struct EditDialogContext'
1289 */
1290void
1291GNS_edit_pkey_dialog_response_cb (GtkDialog *dialog,
1292 gint response_id,
1293 gpointer user_data)
1294{
1295 struct EditDialogContext *edc = user_data;
1296 GtkEntry *entry;
1297 const gchar *value;
1298
1299 if (GTK_RESPONSE_OK == response_id)
1300 {
1301 edit_dialog_putes_common_elements (edc);
1302 entry = GTK_ENTRY (gtk_builder_get_object (edc->builder,
1303 "edit_dialog_pkey_entry"));
1304 value = gtk_entry_get_text (entry);
1305 g_free (edc->n_value);
1306 edc->n_value = g_strdup (value);
1307 }
1308 gtk_widget_destroy (GTK_WIDGET (edc->dialog));
1309 g_object_unref (edc->builder);
1310 edc->builder = NULL;
1311 edc->cont (edc, response_id);
1312}
1313
1314
1315/**
1316 * The user has edited the PKEY record value. Enable/disable 'save'
1317 * button depending on the validity of the value.
1318 *
1319 * @param entry editing widget
1320 * @param user_data the 'struct EditDialogContext' of the dialog
1321 */
1322void
1323GNS_edit_dialog_pkey_entry_changed_cb (GtkEditable *entry,
1324 gpointer user_data)
1325{
1326 struct EditDialogContext *edc = user_data;
1327
1328 edit_dialog_pkey_validity_check (edc);
1329}
1330
1331
1332/**
1333 * Run an GNS Edit dialog for an 'PKEY' Record.
1334 *
1335 * @param edc editing context to use
1336 */
1337void
1338GNS_edit_dialog_pkey (struct EditDialogContext *edc)
1339{
1340 edc->builder = GNUNET_GTK_get_new_builder ("gnunet_namestore_edit_pkey.glade",
1341 edc);
1342 if (NULL == edc->builder)
1343 {
1344 GNUNET_break (0);
1345 edc->cont (edc, GTK_RESPONSE_CANCEL); /* treat as 'cancel' */
1346 return;
1347 }
1348 if (GNUNET_YES ==
1349 edc->old_record_in_namestore)
1350 {
1351 /* set PKEY record */
1352 gtk_entry_set_text (GTK_ENTRY (gtk_builder_get_object (edc->builder,
1353 "edit_dialog_pkey_entry")),
1354 edc->n_value);
1355 }
1356 edc->validator = &edit_dialog_pkey_validity_check;
1357 edc->dialog = GTK_DIALOG (gtk_builder_get_object (edc->builder,
1358 "edit_pkey_dialog"));
1359 run_edit_dialog (edc);
1360}
1361
1362
1363/* ************************ PTR records *********************** */
1364
1365/**
1366 * Check validity of the value in the edit dialog for PTR-records.
1367 * Then call the shared validity check if the result is OK.
1368 *
1369 * @param edc edit dialog context
1370 */
1371static void
1372edit_dialog_ptr_validity_check (struct EditDialogContext *edc)
1373{
1374 GtkEditable *entry;
1375 const gchar *preedit;
1376
1377 entry = GTK_EDITABLE (gtk_builder_get_object (edc->builder,
1378 "edit_dialog_ptr_entry")),
1379 preedit = gtk_editable_get_chars (entry, 0, -1);
1380 if ( (NULL == preedit) ||
1381 (GNUNET_OK != GNUNET_DNSPARSER_check_name (preedit)) )
1382 {
1383 edit_dialog_disable_save (edc);
1384 return;
1385 }
1386 edit_dialog_check_save (edc);
1387}
1388
1389
1390/**
1391 * Editing dialog was closed, get the data and call the
1392 * continuation.
1393 *
1394 * @param dialog editing dialog
1395 * @param response_id action that caused the dialog to be closed
1396 * @param user_data the 'struct EditDialogContext'
1397 */
1398void
1399GNS_edit_ptr_dialog_response_cb (GtkDialog *dialog,
1400 gint response_id,
1401 gpointer user_data)
1402{
1403 struct EditDialogContext *edc = user_data;
1404 GtkEntry *entry;
1405 const gchar *value;
1406
1407 if (GTK_RESPONSE_OK == response_id)
1408 {
1409 edit_dialog_putes_common_elements (edc);
1410 entry = GTK_ENTRY (gtk_builder_get_object (edc->builder,
1411 "edit_dialog_ptr_entry"));
1412 value = gtk_entry_get_text (entry);
1413 g_free (edc->n_value);
1414 edc->n_value = g_strdup (value);
1415 }
1416 gtk_widget_destroy (GTK_WIDGET (edc->dialog));
1417 g_object_unref (edc->builder);
1418 edc->builder = NULL;
1419 edc->cont (edc, response_id);
1420}
1421
1422
1423/**
1424 * The user has edited the PTR record value. Enable/disable 'save'
1425 * button depending on the validity of the value.
1426 *
1427 * @param entry editing widget
1428 * @param user_data the 'struct EditDialogContext' of the dialog
1429 */
1430void
1431GNS_edit_dialog_ptr_entry_changed_cb (GtkEditable *entry,
1432 gpointer user_data)
1433{
1434 struct EditDialogContext *edc = user_data;
1435
1436 edit_dialog_ptr_validity_check (edc);
1437}
1438
1439
1440/**
1441 * Run an GNS Edit dialog for an 'PTR' Record.
1442 *
1443 * @param edc editing context to use
1444 */
1445void
1446GNS_edit_dialog_ptr (struct EditDialogContext *edc)
1447{
1448 edc->builder = GNUNET_GTK_get_new_builder ("gnunet_namestore_edit_ptr.glade",
1449 edc);
1450 if (NULL == edc->builder)
1451 {
1452 GNUNET_break (0);
1453 edc->cont (edc, GTK_RESPONSE_CANCEL); /* treat as 'cancel' */
1454 return;
1455 }
1456 if (GNUNET_YES ==
1457 edc->old_record_in_namestore)
1458 {
1459 /* set PTR record */
1460 gtk_entry_set_text (GTK_ENTRY (gtk_builder_get_object (edc->builder,
1461 "edit_dialog_ptr_entry")),
1462 edc->n_value);
1463 }
1464 edc->validator = &edit_dialog_ptr_validity_check;
1465 edc->dialog = GTK_DIALOG (gtk_builder_get_object (edc->builder,
1466 "edit_ptr_dialog"));
1467 run_edit_dialog (edc);
1468}
1469
1470
1471/* ************************ SOA records *********************** */
1472
1473/**
1474 * Check validity of the value in the edit dialog for SOA-records.
1475 * Then call the shared validity check if the result is OK.
1476 *
1477 * @param edc edit dialog context
1478 */
1479static void
1480edit_dialog_soa_validity_check (struct EditDialogContext *edc)
1481{
1482 GtkEditable *entry;
1483 const gchar *preedit;
1484
1485 entry = GTK_EDITABLE (gtk_builder_get_object (edc->builder,
1486 "edit_dialog_soa_source_host_entry")),
1487 preedit = gtk_editable_get_chars (entry, 0, -1);
1488 if ( (NULL == preedit) ||
1489 (GNUNET_OK != GNUNET_DNSPARSER_check_name (preedit)) )
1490 {
1491 edit_dialog_disable_save (edc);
1492 return;
1493 }
1494 /* check for '@' in the e-mail --- required format uses "." instead! */
1495 entry = GTK_EDITABLE (gtk_builder_get_object (edc->builder,
1496 "edit_dialog_soa_contact_email_entry")),
1497 preedit = gtk_editable_get_chars (entry, 0, -1);
1498 if ( (NULL == preedit) ||
1499 (NULL != strstr (preedit, "@")) ||
1500 (GNUNET_OK != GNUNET_DNSPARSER_check_name (preedit)) )
1501 {
1502 /* E-mail is specified in the RFC also as a 'domain-name', hence
1503 we check above that it follows those conventions as well; the '@'
1504 is a common mistake, and while it should be illegal despite IDN,
1505 it feels better to check explicitly. */
1506 edit_dialog_disable_save (edc);
1507 return;
1508 }
1509 edit_dialog_check_save (edc);
1510}
1511
1512
1513/**
1514 * Editing dialog was closed, get the data and call the
1515 * continuation.
1516 *
1517 * @param dialog editing dialog
1518 * @param response_id action that caused the dialog to be closed
1519 * @param user_data the 'struct EditDialogContext'
1520 */
1521void
1522GNS_edit_soa_dialog_response_cb (GtkDialog *dialog,
1523 gint response_id,
1524 gpointer user_data)
1525{
1526 struct EditDialogContext *edc = user_data;
1527 GtkEntry *entry;
1528 const gchar *source_host;
1529 const gchar *contact_email;
1530 unsigned int soa_serial;
1531 unsigned int soa_refresh;
1532 unsigned int soa_retry;
1533 unsigned int soa_expire;
1534 unsigned int soa_min;
1535 char *result;
1536
1537 if (GTK_RESPONSE_OK == response_id)
1538 {
1539 edit_dialog_putes_common_elements (edc);
1540 entry = GTK_ENTRY (gtk_builder_get_object (edc->builder,
1541 "edit_dialog_soa_source_host_entry"));
1542 source_host = gtk_entry_get_text (entry);
1543 entry = GTK_ENTRY (gtk_builder_get_object (edc->builder,
1544 "edit_dialog_soa_contact_email_entry"));
1545 contact_email = gtk_entry_get_text (entry);
1546 soa_serial = gtk_spin_button_get_value (GTK_SPIN_BUTTON (gtk_builder_get_object (edc->builder,
1547 "edit_dialog_soa_serial_number_spinbutton")));
1548 soa_refresh = gtk_spin_button_get_value (GTK_SPIN_BUTTON (gtk_builder_get_object (edc->builder,
1549 "edit_dialog_soa_refresh_time_spinbutton")));
1550 soa_retry = gtk_spin_button_get_value (GTK_SPIN_BUTTON (gtk_builder_get_object (edc->builder,
1551 "edit_dialog_soa_retry_time_spinbutton")));
1552 soa_expire = gtk_spin_button_get_value (GTK_SPIN_BUTTON (gtk_builder_get_object (edc->builder,
1553 "edit_dialog_soa_expire_time_spinbutton")));
1554 soa_min = gtk_spin_button_get_value (GTK_SPIN_BUTTON (gtk_builder_get_object (edc->builder,
1555 "edit_dialog_soa_minimum_ttl_spinbutton")));
1556 GNUNET_asprintf (&result,
1557 "rname=%s mname=%s %lu,%lu,%lu,%lu,%lu",
1558 source_host, contact_email,
1559 soa_serial,
1560 soa_refresh,
1561 soa_retry,
1562 soa_expire,
1563 soa_min);
1564 edc->n_value = g_strdup (result);
1565 GNUNET_free (result);
1566 }
1567 gtk_widget_destroy (GTK_WIDGET (edc->dialog));
1568 g_object_unref (edc->builder);
1569 edc->builder = NULL;
1570 edc->cont (edc, response_id);
1571}
1572
1573
1574/**
1575 * The user has edited the SOA record value. Enable/disable 'save'
1576 * button depending on the validity of the value.
1577 *
1578 * @param entry editing widget
1579 * @param user_data the 'struct EditDialogContext' of the dialog
1580 */
1581void
1582GNS_edit_dialog_soa_contact_email_entry_changed_cb (GtkEditable *entry,
1583 gpointer user_data)
1584{
1585 struct EditDialogContext *edc = user_data;
1586
1587 edit_dialog_soa_validity_check (edc);
1588}
1589
1590
1591/**
1592 * The user has edited the SOA record value. Enable/disable 'save'
1593 * button depending on the validity of the value.
1594 *
1595 * @param entry editing widget
1596 * @param user_data the 'struct EditDialogContext' of the dialog
1597 */
1598void
1599GNS_edit_dialog_soa_source_host_entry_changed_cb (GtkEditable *entry,
1600 gpointer user_data)
1601{
1602 struct EditDialogContext *edc = user_data;
1603
1604 edit_dialog_soa_validity_check (edc);
1605}
1606
1607
1608/**
1609 * Run an GNS Edit dialog for an 'SOA' Record.
1610 *
1611 * @param edc editing context to use
1612 */
1613void
1614GNS_edit_dialog_soa (struct EditDialogContext *edc)
1615{
1616 char soa_rname[253 + 1];
1617 char soa_mname[253 + 1];
1618 unsigned int soa_serial;
1619 unsigned int soa_refresh;
1620 unsigned int soa_retry;
1621 unsigned int soa_expire;
1622 unsigned int soa_min;
1623
1624 edc->builder = GNUNET_GTK_get_new_builder ("gnunet_namestore_edit_soa.glade",
1625 edc);
1626 if (NULL == edc->builder)
1627 {
1628 GNUNET_break (0);
1629 edc->cont (edc, GTK_RESPONSE_CANCEL); /* treat as 'cancel' */
1630 return;
1631 }
1632 if (GNUNET_YES ==
1633 edc->old_record_in_namestore)
1634 {
1635 if (7 != SSCANF (edc->n_value,
1636 "rname=%253s mname=%253s %u,%u,%u,%u,%u",
1637 soa_rname, soa_mname,
1638 &soa_serial, &soa_refresh, &soa_retry, &soa_expire, &soa_min))
1639 {
1640 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1641 _("Unable to parse SOA record `%s'\n"),
1642 edc->n_value);
1643 }
1644 else
1645 {
1646 /* set SOA record */
1647 gtk_entry_set_text (GTK_ENTRY (gtk_builder_get_object (edc->builder,
1648 "edit_dialog_soa_source_host_entry")),
1649 soa_rname);
1650 gtk_entry_set_text (GTK_ENTRY (gtk_builder_get_object (edc->builder,
1651 "edit_dialog_soa_contact_email_entry")),
1652 soa_mname);
1653 gtk_spin_button_set_value (GTK_SPIN_BUTTON (gtk_builder_get_object (edc->builder,
1654 "edit_dialog_soa_serial_number_spinbutton")),
1655 soa_serial);
1656 gtk_spin_button_set_value (GTK_SPIN_BUTTON (gtk_builder_get_object (edc->builder,
1657 "edit_dialog_soa_refresh_time_spinbutton")),
1658 soa_refresh);
1659 gtk_spin_button_set_value (GTK_SPIN_BUTTON (gtk_builder_get_object (edc->builder,
1660 "edit_dialog_soa_retry_time_spinbutton")),
1661 soa_retry);
1662 gtk_spin_button_set_value (GTK_SPIN_BUTTON (gtk_builder_get_object (edc->builder,
1663 "edit_dialog_soa_expire_time_spinbutton")),
1664 soa_expire);
1665 gtk_spin_button_set_value (GTK_SPIN_BUTTON (gtk_builder_get_object (edc->builder,
1666 "edit_dialog_soa_minimum_ttl_spinbutton")),
1667 soa_min);
1668 }
1669 }
1670 edc->validator = &edit_dialog_soa_validity_check;
1671 edc->dialog = GTK_DIALOG (gtk_builder_get_object (edc->builder,
1672 "edit_soa_dialog"));
1673 run_edit_dialog (edc);
1674}
1675
1676
1677/* ************************ SRV records *********************** */
1678/* *** Not implemented: namestore_common.c as well as here! *** */
1679/* ************************ SRV records *********************** */
1680
1681/**
1682 * Check validity of the value in the edit dialog for SRV-records.
1683 * Then call the shared validity check if the result is OK.
1684 *
1685 * @param edc edit dialog context
1686 */
1687static void
1688edit_dialog_srv_validity_check (struct EditDialogContext *edc)
1689{
1690 GtkEditable *entry;
1691 const gchar *preedit;
1692
1693 entry = GTK_EDITABLE (gtk_builder_get_object (edc->builder,
1694 "edit_dialog_srv_target_entry")),
1695 preedit = gtk_editable_get_chars (entry, 0, -1);
1696 if ( (NULL == preedit) ||
1697 (GNUNET_OK != GNUNET_DNSPARSER_check_name (preedit)) )
1698 {
1699 edit_dialog_disable_save (edc);
1700 return;
1701 }
1702 entry = GTK_EDITABLE (gtk_builder_get_object (edc->builder,
1703 "edit_dialog_name_entry")),
1704 preedit = gtk_editable_get_chars (entry, 0, -1);
1705#if 0
1706 /* FIXME: check service name format! */
1707#endif
1708 edit_dialog_check_save (edc);
1709}
1710
1711
1712/**
1713 * Editing dialog was closed, get the data and call the
1714 * continuation.
1715 *
1716 * @param dialog editing dialog
1717 * @param response_id action that caused the dialog to be closed
1718 * @param user_data the 'struct EditDialogContext'
1719 */
1720void
1721GNS_edit_srv_dialog_response_cb (GtkDialog *dialog,
1722 gint response_id,
1723 gpointer user_data)
1724{
1725 struct EditDialogContext *edc = user_data;
1726
1727 if (GTK_RESPONSE_OK == response_id)
1728 {
1729 edit_dialog_putes_common_elements (edc);
1730#if 0
1731 GtkEntry *entry;
1732 const gchar *value;
1733
1734 entry = GTK_ENTRY (gtk_builder_get_object (edc->builder,
1735 "edit_dialog_srv_target_entry"));
1736 /* FIXME: build srv record */
1737 value = gtk_entry_get_text (entry);
1738 g_free (edc->n_value);
1739 edc->n_value = g_strdup (value);
1740#endif
1741
1742 }
1743 gtk_widget_destroy (GTK_WIDGET (edc->dialog));
1744 g_object_unref (edc->builder);
1745 edc->builder = NULL;
1746 edc->cont (edc, response_id);
1747}
1748
1749
1750/**
1751 * The user has edited the SRV record value. Enable/disable 'save'
1752 * button depending on the validity of the value.
1753 *
1754 * @param entry editing widget
1755 * @param user_data the 'struct EditDialogContext' of the dialog
1756 */
1757void
1758GNS_edit_dialog_srv_target_entry_changed_cb (GtkEditable *entry,
1759 gpointer user_data)
1760{
1761 struct EditDialogContext *edc = user_data;
1762
1763 edit_dialog_srv_validity_check (edc);
1764}
1765
1766
1767/**
1768 * Run an GNS Edit dialog for an 'SRV' Record.
1769 *
1770 * @param edc editing context to use
1771 */
1772void
1773GNS_edit_dialog_srv (struct EditDialogContext *edc)
1774{
1775 edc->builder = GNUNET_GTK_get_new_builder ("gnunet_namestore_edit_srv.glade",
1776 edc);
1777 if (NULL == edc->builder)
1778 {
1779 GNUNET_break (0);
1780 edc->cont (edc, GTK_RESPONSE_CANCEL); /* treat as 'cancel' */
1781 return;
1782 }
1783 if (GNUNET_YES ==
1784 edc->old_record_in_namestore)
1785 {
1786#if 0
1787 /* FIXME */
1788 /* set SRV record */
1789 gtk_entry_set_text (GTK_ENTRY (gtk_builder_get_object (edc->builder,
1790 "edit_dialog_srv_target_entry")),
1791 edc->n_value);
1792#endif
1793 }
1794 edc->validator = &edit_dialog_srv_validity_check;
1795 edc->dialog = GTK_DIALOG (gtk_builder_get_object (edc->builder,
1796 "edit_srv_dialog"));
1797 run_edit_dialog (edc);
1798}
1799
1800
1801/* ************************ TXT records *********************** */
1802
1803/**
1804 * Check validity of the value in the edit dialog for TXT-records.
1805 * Then call the shared validity check if the result is OK.
1806 *
1807 * @param edc edit dialog context
1808 */
1809static void
1810edit_dialog_txt_validity_check (struct EditDialogContext *edc)
1811{
1812 edit_dialog_check_save (edc);
1813}
1814
1815
1816/**
1817 * Editing dialog was closed, get the data and call the
1818 * continuation.
1819 *
1820 * @param dialog editing dialog
1821 * @param response_id action that caused the dialog to be closed
1822 * @param user_data the 'struct EditDialogContext'
1823 */
1824void
1825GNS_edit_txt_dialog_response_cb (GtkDialog *dialog,
1826 gint response_id,
1827 gpointer user_data)
1828{
1829 struct EditDialogContext *edc = user_data;
1830 GtkEntry *entry;
1831 const gchar *value;
1832
1833 if (GTK_RESPONSE_OK == response_id)
1834 {
1835 edit_dialog_putes_common_elements (edc);
1836 entry = GTK_ENTRY (gtk_builder_get_object (edc->builder,
1837 "edit_dialog_txt_entry"));
1838 value = gtk_entry_get_text (entry);
1839 g_free (edc->n_value);
1840 edc->n_value = g_strdup (value);
1841 }
1842 gtk_widget_destroy (GTK_WIDGET (edc->dialog));
1843 g_object_unref (edc->builder);
1844 edc->builder = NULL;
1845 edc->cont (edc, response_id);
1846}
1847
1848
1849/**
1850 * The user has edited the TXT record value. Enable/disable 'save'
1851 * button depending on the validity of the value.
1852 *
1853 * @param entry editing widget
1854 * @param user_data the 'struct EditDialogContext' of the dialog
1855 */
1856void
1857GNS_edit_dialog_txt_entry_changed_cb (GtkEditable *entry,
1858 gpointer user_data)
1859{
1860 struct EditDialogContext *edc = user_data;
1861
1862 edit_dialog_txt_validity_check (edc);
1863}
1864
1865
1866/**
1867 * Run an GNS Edit dialog for an 'TXT' Record.
1868 *
1869 * @param edc editing context to use
1870 */
1871void
1872GNS_edit_dialog_txt (struct EditDialogContext *edc)
1873{
1874 edc->builder = GNUNET_GTK_get_new_builder ("gnunet_namestore_edit_txt.glade",
1875 edc);
1876 if (NULL == edc->builder)
1877 {
1878 GNUNET_break (0);
1879 edc->cont (edc, GTK_RESPONSE_CANCEL); /* treat as 'cancel' */
1880 return;
1881 }
1882 if (GNUNET_YES ==
1883 edc->old_record_in_namestore)
1884 {
1885 /* set TXT record */
1886 gtk_entry_set_text (GTK_ENTRY (gtk_builder_get_object (edc->builder,
1887 "edit_dialog_txt_entry")),
1888 edc->n_value);
1889 }
1890 edc->validator = &edit_dialog_txt_validity_check;
1891 edc->dialog = GTK_DIALOG (gtk_builder_get_object (edc->builder,
1892 "edit_txt_dialog"));
1893 run_edit_dialog (edc);
1894}
1895
1896
1897/* ************************ VPN records *********************** */
1898
1899/**
1900 * Check validity of the value in the edit dialog for VPN-records.
1901 * Then call the shared validity check if the result is OK.
1902 *
1903 * @param edc edit dialog context
1904 */
1905static void
1906edit_dialog_vpn_validity_check (struct EditDialogContext *edc)
1907{
1908 GtkEditable *entry;
1909 const gchar *preedit;
1910 struct GNUNET_HashCode hc;
1911
1912 entry = GTK_EDITABLE (gtk_builder_get_object (edc->builder,
1913 "edit_dialog_vpn_peer_entry")),
1914 preedit = gtk_editable_get_chars (entry, 0, -1);
1915 if ( (NULL == preedit) ||
1916 (GNUNET_OK !=
1917 GNUNET_CRYPTO_hash_from_string (preedit, &hc)) )
1918 {
1919 edit_dialog_disable_save (edc);
1920 return;
1921 }
1922 edit_dialog_check_save (edc);
1923}
1924
1925
1926/**
1927 * Editing dialog was closed, get the data and call the
1928 * continuation.
1929 *
1930 * @param dialog editing dialog
1931 * @param response_id action that caused the dialog to be closed
1932 * @param user_data the 'struct EditDialogContext'
1933 */
1934void
1935GNS_edit_vpn_dialog_response_cb (GtkDialog *dialog,
1936 gint response_id,
1937 gpointer user_data)
1938{
1939 struct EditDialogContext *edc = user_data;
1940 GtkEntry *entry;
1941 const gchar *identifier;
1942 const gchar *peer;
1943 unsigned int proto;
1944 char *result;
1945
1946 if (GTK_RESPONSE_OK == response_id)
1947 {
1948 edit_dialog_putes_common_elements (edc);
1949 entry = GTK_ENTRY (gtk_builder_get_object (edc->builder,
1950 "edit_dialog_vpn_identifier_entry"));
1951 identifier = gtk_entry_get_text (entry);
1952 entry = GTK_ENTRY (gtk_builder_get_object (edc->builder,
1953 "edit_dialog_vpn_peer_entry"));
1954 peer = gtk_entry_get_text (entry);
1955 proto = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (edc->builder,
1956 "edit_dialog_vpn_protocol_tcp_radiobutton"))) ? IPPROTO_TCP : IPPROTO_UDP;
1957 GNUNET_asprintf (&result,
1958 "%u %s %s",
1959 proto,
1960 (const char *) peer,
1961 (const char *) identifier);
1962 g_free (edc->n_value);
1963 edc->n_value = g_strdup (result);
1964 GNUNET_free (result);
1965 }
1966 gtk_widget_destroy (GTK_WIDGET (edc->dialog));
1967 g_object_unref (edc->builder);
1968 edc->builder = NULL;
1969 edc->cont (edc, response_id);
1970}
1971
1972
1973/**
1974 * The user has edited the VPN record value. Enable/disable 'save'
1975 * button depending on the validity of the value.
1976 *
1977 * @param entry editing widget
1978 * @param user_data the 'struct EditDialogContext' of the dialog
1979 */
1980void
1981GNS_edit_dialog_vpn_peer_entry_changed_cb (GtkEditable *entry,
1982 gpointer user_data)
1983{
1984 struct EditDialogContext *edc = user_data;
1985
1986 edit_dialog_vpn_validity_check (edc);
1987}
1988
1989
1990/**
1991 * Run an GNS Edit dialog for an 'VPN' Record.
1992 *
1993 * @param edc editing context to use
1994 */
1995void
1996GNS_edit_dialog_vpn (struct EditDialogContext *edc)
1997{
1998 char s_peer[103 + 1];
1999 char s_serv[253 + 1];
2000 unsigned int proto;
2001
2002 edc->builder = GNUNET_GTK_get_new_builder ("gnunet_namestore_edit_vpn.glade",
2003 edc);
2004 if (NULL == edc->builder)
2005 {
2006 GNUNET_break (0);
2007 edc->cont (edc, GTK_RESPONSE_CANCEL); /* treat as 'cancel' */
2008 return;
2009 }
2010 if (GNUNET_YES ==
2011 edc->old_record_in_namestore)
2012 {
2013 /* set VPN record */
2014 if (3 != SSCANF (edc->n_value,"%u %103s %253s",
2015 &proto, s_peer, s_serv))
2016 {
2017 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
2018 _("Unable to parse VPN record string `%s'\n"),
2019 edc->n_value);
2020 }
2021 else
2022 {
2023 gtk_entry_set_text (GTK_ENTRY (gtk_builder_get_object (edc->builder,
2024 "edit_dialog_vpn_identifier_entry")),
2025 s_serv);
2026 gtk_entry_set_text (GTK_ENTRY (gtk_builder_get_object (edc->builder,
2027 "edit_dialog_vpn_peer_entry")),
2028 s_peer);
2029 if (IPPROTO_UDP == proto)
2030 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (edc->builder,
2031 "edit_dialog_vpn_protocol_udp_radiobutton")), TRUE);
2032 else
2033 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (edc->builder,
2034 "edit_dialog_vpn_protocol_tcp_radiobutton")), TRUE);
2035 }
2036 }
2037 edc->validator = &edit_dialog_vpn_validity_check;
2038 edc->dialog = GTK_DIALOG (gtk_builder_get_object (edc->builder,
2039 "edit_vpn_dialog"));
2040 run_edit_dialog (edc);
2041}
2042
2043 94
2044/* end of gnunet-namestore-gtk_edit.c */ 95/* end of gnunet-namestore-gtk_edit.c */
diff --git a/src/namestore/gnunet-namestore-gtk_edit.h b/src/namestore/gnunet-namestore-gtk_edit.h
deleted file mode 100644
index dc8f0571..00000000
--- a/src/namestore/gnunet-namestore-gtk_edit.h
+++ /dev/null
@@ -1,292 +0,0 @@
1/*
2 This file is part of GNUnet
3 (C) 2012, 2013 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 3, 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/namestore/gnunet-namestore-gtk_edit.h
23 * @author Christian Grothoff
24 * @brief editing dialogs for GNS records
25 */
26#ifndef GNUNET_SETUP_GNS_EDIT_H
27#define GNUNET_SETUP_GNS_EDIT_H
28
29#include "gnunet_gtk.h"
30#include <gnunet/gnunet_namestore_service.h>
31#include <gnunet/gnunet_dnsparser_lib.h>
32
33
34/**
35 * Columns in the zone list store.
36 */
37enum ZONE_COLUMNS
38{
39
40 /**
41 * A gchararray
42 */
43 ZONE_LS_NAME = 0,
44
45
46 /**
47 * A `struct GNUNET_IDENTITY_Ego`
48 */
49 ZONE_LS_EGO = 1
50};
51
52
53
54/**
55 * Context for edit operations.
56 */
57struct EditDialogContext;
58
59
60/**
61 * Signature of the continuation function invoked once the
62 * edit dialog is done.
63 *
64 * @param edc dialog context
65 * @param ret return code from the dialog
66 */
67typedef void (*GNS_EditContinuation)(struct EditDialogContext *edc,
68 GtkResponseType ret);
69
70
71/**
72 * Signature of a dialog-specific validation function to validate the
73 * value. Should either call 'edit_dialog_disable_save' if the value
74 * is invalid, or 'edit_dialog_check_save' if the value is valid.
75 */
76typedef void (*GNS_EditValidator)(struct EditDialogContext *edc);
77
78
79/**
80 * Context for edit operations.
81 */
82struct EditDialogContext
83{
84
85 /**
86 * Where in the tree view are we editing?
87 */
88 struct RecordInfo *ri;
89
90 /**
91 * Function to call at the end.
92 */
93 GNS_EditContinuation cont;
94
95 /**
96 * Function to call to validate the state of the dialog and
97 * ultimately update the 'save' button sensitivity.
98 */
99 GNS_EditValidator validator;
100
101 /**
102 * Builder for the dialog (internal to gnunet-setup-gns-edit.c).
103 */
104 GtkBuilder *builder;
105
106 /**
107 * Main dialog window.
108 */
109 GtkDialog *dialog;
110
111 /**
112 * Name of the record.
113 */
114 gchar *name;
115
116 /**
117 * Value of the record in string format.
118 */
119 gchar *n_value;
120
121 /**
122 * Name of the zone into which the record should be placed.
123 */
124 gchar *new_zone_option;
125
126 /**
127 * Ego of the zone into which the record should be placed.
128 */
129 struct GNUNET_IDENTITY_Ego *ego;
130
131 /**
132 * Expiration time value (absolute or relative).
133 */
134 guint64 n_exp_time;
135
136 /**
137 * Offset of the record we are editing in the 'rd' list of 'ri'.
138 */
139 unsigned int off;
140
141 /**
142 * Flag indicating if the old record was in the namestore.
143 */
144 int old_record_in_namestore;
145
146 /**
147 * Type of the record.
148 */
149 uint32_t record_type;
150
151 /**
152 * Is this record 'public'?
153 */
154 gboolean n_public;
155
156 /**
157 * Is the expiration time relative?
158 */
159 gboolean n_is_relative;
160
161 /**
162 * Is this record a shadow record?
163 */
164 gboolean n_is_shadow;
165
166 /**
167 * List of all zones.
168 */
169 GtkListStore *zone_liststore;
170
171};
172
173
174
175/**
176 * Run an GNS Edit dialog for an 'A' Record.
177 *
178 * @param edc editing context to use
179 */
180void
181GNS_edit_dialog_a (struct EditDialogContext *edc);
182
183
184/**
185 * Run an GNS Edit dialog for an 'AAAA' Record.
186 *
187 * @param edc editing context to use
188 */
189void
190GNS_edit_dialog_aaaa (struct EditDialogContext *edc);
191
192
193/**
194 * Run an GNS Edit dialog for an 'CNAME' Record.
195 *
196 * @param edc editing context to use
197 */
198void
199GNS_edit_dialog_cname (struct EditDialogContext *edc);
200
201
202/**
203 * Run an GNS Edit dialog for an 'LEHO' Record.
204 *
205 * @param edc editing context to use
206 */
207void
208GNS_edit_dialog_leho (struct EditDialogContext *edc);
209
210
211/**
212 * Run an GNS Edit dialog for an 'MX' Record.
213 *
214 * @param edc editing context to use
215 */
216void
217GNS_edit_dialog_mx (struct EditDialogContext *edc);
218
219
220/**
221 * Run an GNS Edit dialog for an 'NS' Record.
222 *
223 * @param edc editing context to use
224 */
225void
226GNS_edit_dialog_gns2dns (struct EditDialogContext *edc);
227
228
229/**
230 * Run an GNS Edit dialog for a 'PHONE' Record.
231 *
232 * @param edc editing context to use
233 */
234void
235GNS_edit_dialog_phone (struct EditDialogContext *edc);
236
237
238/**
239 * Run an GNS Edit dialog for an 'PKEY' Record.
240 *
241 * @param edc editing context to use
242 */
243void
244GNS_edit_dialog_pkey (struct EditDialogContext *edc);
245
246
247/**
248 * Run an GNS Edit dialog for an 'PTR' Record.
249 *
250 * @param edc editing context to use
251 */
252void
253GNS_edit_dialog_ptr (struct EditDialogContext *edc);
254
255
256/**
257 * Run an GNS Edit dialog for an 'SOA' Record.
258 *
259 * @param edc editing context to use
260 */
261void
262GNS_edit_dialog_soa (struct EditDialogContext *edc);
263
264
265/**
266 * Run an GNS Edit dialog for an 'SRV' Record.
267 *
268 * @param edc editing context to use
269 */
270void
271GNS_edit_dialog_srv (struct EditDialogContext *edc);
272
273
274/**
275 * Run an GNS Edit dialog for an 'TXT' Record.
276 *
277 * @param edc editing context to use
278 */
279void
280GNS_edit_dialog_txt (struct EditDialogContext *edc);
281
282
283/**
284 * Run an GNS Edit dialog for an 'VPN' Record.
285 *
286 * @param edc editing context to use
287 */
288void
289GNS_edit_dialog_vpn (struct EditDialogContext *edc);
290
291
292#endif
diff --git a/src/namestore/plugin_gtk_namestore_a.c b/src/namestore/plugin_gtk_namestore_a.c
index d72373e9..c4f302f2 100644
--- a/src/namestore/plugin_gtk_namestore_a.c
+++ b/src/namestore/plugin_gtk_namestore_a.c
@@ -34,13 +34,13 @@
34 * @param entry editing widget 34 * @param entry editing widget
35 * @param user_data the plugin environment 35 * @param user_data the plugin environment
36 */ 36 */
37void 37static void
38GNS_edit_dialog_a_entry_changed_cb (GtkEditable *entry, 38GNS_edit_dialog_a_entry_changed_cb (GtkEditable *entry,
39 gpointer user_data) 39 gpointer user_data)
40{ 40{
41 struct GNUNET_GTK_NAMESTORE_PluginEnvironment *env = user_data; 41 struct GNUNET_GTK_NAMESTORE_PluginEnvironment *edc = user_data;
42 42
43 env->check_validity (env->cls); 43 edc->check_validity (edc);
44} 44}
45 45
46 46
@@ -121,7 +121,7 @@ a_validate (void *cls,
121/** 121/**
122 * Entry point for the plugin. 122 * Entry point for the plugin.
123 * 123 *
124 * @param cls the "struct GNUNET_GTK_NAMESTORE_PluginEnvironment*" 124 * @param cls the `struct GNUNET_GTK_NAMESTORE_PluginEnvironment`
125 * @return NULL on error, otherwise the plugin context 125 * @return NULL on error, otherwise the plugin context
126 */ 126 */
127void * 127void *
@@ -129,11 +129,17 @@ libgnunet_plugin_gtk_namestore_a_init (void *cls)
129{ 129{
130 struct GNUNET_GTK_NAMESTORE_PluginEnvironment *env = cls; 130 struct GNUNET_GTK_NAMESTORE_PluginEnvironment *env = cls;
131 struct GNUNET_GTK_NAMESTORE_PluginFunctions *plugin; 131 struct GNUNET_GTK_NAMESTORE_PluginFunctions *plugin;
132 static struct GNUNET_GTK_NAMESTORE_Symbol symbols[] = {
133 { "GNS_edit_dialog_a_entry_changed_cb",
134 G_CALLBACK (GNS_edit_dialog_a_entry_changed_cb) },
135 { NULL, NULL }
136 };
132 137
133 plugin = GNUNET_new (struct GNUNET_GTK_NAMESTORE_PluginFunctions); 138 plugin = GNUNET_new (struct GNUNET_GTK_NAMESTORE_PluginFunctions);
134 plugin->cls = env; 139 plugin->cls = env;
135 plugin->dialog_glade_filename = "gnunet_namestore_edit_a.glade"; 140 plugin->dialog_glade_filename = "gnunet_namestore_edit_a.glade";
136 plugin->dialog_widget_name = "edit_a_dialog"; 141 plugin->dialog_widget_name = "edit_a_dialog";
142 plugin->symbols = symbols;
137 plugin->load = &a_load; 143 plugin->load = &a_load;
138 plugin->store = &a_store; 144 plugin->store = &a_store;
139 plugin->validate = &a_validate; 145 plugin->validate = &a_validate;
diff --git a/src/namestore/plugin_gtk_namestore_aaaa.c b/src/namestore/plugin_gtk_namestore_aaaa.c
index 08da0bec..76b64dcb 100644
--- a/src/namestore/plugin_gtk_namestore_aaaa.c
+++ b/src/namestore/plugin_gtk_namestore_aaaa.c
@@ -34,13 +34,13 @@
34 * @param entry editing widget 34 * @param entry editing widget
35 * @param user_data the plugin environment 35 * @param user_data the plugin environment
36 */ 36 */
37void 37static void
38GNS_edit_dialog_aaaa_entry_changed_cb (GtkEditable *entry, 38GNS_edit_dialog_aaaa_entry_changed_cb (GtkEditable *entry,
39 gpointer user_data) 39 gpointer user_data)
40{ 40{
41 struct GNUNET_GTK_NAMESTORE_PluginEnvironment *env = user_data; 41 struct GNUNET_GTK_NAMESTORE_PluginEnvironment *edc = user_data;
42 42
43 env->check_validity (env->cls); 43 edc->check_validity (edc);
44} 44}
45 45
46 46
@@ -116,7 +116,7 @@ aaaa_validate (void *cls,
116/** 116/**
117 * Entry point for the plugin. 117 * Entry point for the plugin.
118 * 118 *
119 * @param cls the "struct GNUNET_GTK_NAMESTORE_PluginEnvironment*" 119 * @param cls the `struct GNUNET_GTK_NAMESTORE_PluginEnvironment`
120 * @return NULL on error, otherwise the plugin context 120 * @return NULL on error, otherwise the plugin context
121 */ 121 */
122void * 122void *
@@ -124,11 +124,17 @@ libgnunet_plugin_gtk_namestore_aaaa_init (void *cls)
124{ 124{
125 struct GNUNET_GTK_NAMESTORE_PluginEnvironment *env = cls; 125 struct GNUNET_GTK_NAMESTORE_PluginEnvironment *env = cls;
126 struct GNUNET_GTK_NAMESTORE_PluginFunctions *plugin; 126 struct GNUNET_GTK_NAMESTORE_PluginFunctions *plugin;
127 static struct GNUNET_GTK_NAMESTORE_Symbol symbols[] = {
128 { "GNS_edit_dialog_aaaa_entry_changed_cb",
129 G_CALLBACK (GNS_edit_dialog_aaaa_entry_changed_cb) },
130 { NULL, NULL }
131 };
127 132
128 plugin = GNUNET_new (struct GNUNET_GTK_NAMESTORE_PluginFunctions); 133 plugin = GNUNET_new (struct GNUNET_GTK_NAMESTORE_PluginFunctions);
129 plugin->cls = env; 134 plugin->cls = env;
130 plugin->dialog_glade_filename = "gnunet_namestore_edit_aaaa.glade"; 135 plugin->dialog_glade_filename = "gnunet_namestore_edit_aaaa.glade";
131 plugin->dialog_widget_name = "edit_aaaa_dialog"; 136 plugin->dialog_widget_name = "edit_aaaa_dialog";
137 plugin->symbols = symbols;
132 plugin->load = &aaaa_load; 138 plugin->load = &aaaa_load;
133 plugin->store = &aaaa_store; 139 plugin->store = &aaaa_store;
134 plugin->validate = &aaaa_validate; 140 plugin->validate = &aaaa_validate;
diff --git a/src/namestore/plugin_gtk_namestore_cname.c b/src/namestore/plugin_gtk_namestore_cname.c
index e9f2c119..c8fb176c 100644
--- a/src/namestore/plugin_gtk_namestore_cname.c
+++ b/src/namestore/plugin_gtk_namestore_cname.c
@@ -34,13 +34,13 @@
34 * @param entry editing widget 34 * @param entry editing widget
35 * @param user_data the plugin environment 35 * @param user_data the plugin environment
36 */ 36 */
37void 37static void
38GNS_edit_dialog_cname_entry_changed_cb (GtkEditable *entry, 38GNS_edit_dialog_cname_entry_changed_cb (GtkEditable *entry,
39 gpointer user_data) 39 gpointer user_data)
40{ 40{
41 struct GNUNET_GTK_NAMESTORE_PluginEnvironment *env = user_data; 41 struct GNUNET_GTK_NAMESTORE_PluginEnvironment *edc = user_data;
42 42
43 env->check_validity (env->cls); 43 edc->check_validity (edc);
44} 44}
45 45
46 46
@@ -120,7 +120,7 @@ cname_validate (void *cls,
120/** 120/**
121 * Entry point for the plugin. 121 * Entry point for the plugin.
122 * 122 *
123 * @param cls the "struct GNUNET_GTK_NAMESTORE_PluginEnvironment*" 123 * @param cls the `struct GNUNET_GTK_NAMESTORE_PluginEnvironment`
124 * @return NULL on error, otherwise the plugin context 124 * @return NULL on error, otherwise the plugin context
125 */ 125 */
126void * 126void *
@@ -128,11 +128,17 @@ libgnunet_plugin_gtk_namestore_cname_init (void *cls)
128{ 128{
129 struct GNUNET_GTK_NAMESTORE_PluginEnvironment *env = cls; 129 struct GNUNET_GTK_NAMESTORE_PluginEnvironment *env = cls;
130 struct GNUNET_GTK_NAMESTORE_PluginFunctions *plugin; 130 struct GNUNET_GTK_NAMESTORE_PluginFunctions *plugin;
131 static struct GNUNET_GTK_NAMESTORE_Symbol symbols[] = {
132 { "GNS_edit_dialog_cname_entry_changed_cb",
133 G_CALLBACK (GNS_edit_dialog_cname_entry_changed_cb) },
134 { NULL, NULL }
135 };
131 136
132 plugin = GNUNET_new (struct GNUNET_GTK_NAMESTORE_PluginFunctions); 137 plugin = GNUNET_new (struct GNUNET_GTK_NAMESTORE_PluginFunctions);
133 plugin->cls = env; 138 plugin->cls = env;
134 plugin->dialog_glade_filename = "gnunet_namestore_edit_cname.glade"; 139 plugin->dialog_glade_filename = "gnunet_namestore_edit_cname.glade";
135 plugin->dialog_widget_name = "edit_cname_dialog"; 140 plugin->dialog_widget_name = "edit_cname_dialog";
141 plugin->symbols = symbols;
136 plugin->load = &cname_load; 142 plugin->load = &cname_load;
137 plugin->store = &cname_store; 143 plugin->store = &cname_store;
138 plugin->validate = &cname_validate; 144 plugin->validate = &cname_validate;
diff --git a/src/namestore/plugin_gtk_namestore_gns2dns.c b/src/namestore/plugin_gtk_namestore_gns2dns.c
index 88d41ba9..16ac03fb 100644
--- a/src/namestore/plugin_gtk_namestore_gns2dns.c
+++ b/src/namestore/plugin_gtk_namestore_gns2dns.c
@@ -35,13 +35,13 @@
35 * @param entry editing widget 35 * @param entry editing widget
36 * @param user_data the plugin environment 36 * @param user_data the plugin environment
37 */ 37 */
38void 38static void
39GNS_edit_dialog_gns2dns_entry_changed_cb (GtkEditable *entry, 39GNS_edit_dialog_gns2dns_entry_changed_cb (GtkEditable *entry,
40 gpointer user_data) 40 gpointer user_data)
41{ 41{
42 struct GNUNET_GTK_NAMESTORE_PluginEnvironment *env = user_data; 42 struct GNUNET_GTK_NAMESTORE_PluginEnvironment *edc = user_data;
43 43
44 env->check_validity (env->cls); 44 edc->check_validity (edc);
45} 45}
46 46
47 47
@@ -118,7 +118,7 @@ gns2dns_validate (void *cls,
118/** 118/**
119 * Entry point for the plugin. 119 * Entry point for the plugin.
120 * 120 *
121 * @param cls the "struct GNUNET_GTK_NAMESTORE_PluginEnvironment*" 121 * @param cls the `struct GNUNET_GTK_NAMESTORE_PluginEnvironment`
122 * @return NULL on error, otherwise the plugin context 122 * @return NULL on error, otherwise the plugin context
123 */ 123 */
124void * 124void *
@@ -126,11 +126,17 @@ libgnunet_plugin_gtk_namestore_gns2dns_init (void *cls)
126{ 126{
127 struct GNUNET_GTK_NAMESTORE_PluginEnvironment *env = cls; 127 struct GNUNET_GTK_NAMESTORE_PluginEnvironment *env = cls;
128 struct GNUNET_GTK_NAMESTORE_PluginFunctions *plugin; 128 struct GNUNET_GTK_NAMESTORE_PluginFunctions *plugin;
129 static struct GNUNET_GTK_NAMESTORE_Symbol symbols[] = {
130 { "GNS_edit_dialog_gns2dns_entry_changed_cb",
131 G_CALLBACK (GNS_edit_dialog_gns2dns_entry_changed_cb) },
132 { NULL, NULL }
133 };
129 134
130 plugin = GNUNET_new (struct GNUNET_GTK_NAMESTORE_PluginFunctions); 135 plugin = GNUNET_new (struct GNUNET_GTK_NAMESTORE_PluginFunctions);
131 plugin->cls = env; 136 plugin->cls = env;
132 plugin->dialog_glade_filename = "gnunet_namestore_edit_gns2dns.glade"; 137 plugin->dialog_glade_filename = "gnunet_namestore_edit_gns2dns.glade";
133 plugin->dialog_widget_name = "edit_gns2dns_dialog"; 138 plugin->dialog_widget_name = "edit_gns2dns_dialog";
139 plugin->symbols = symbols;
134 plugin->load = &gns2dns_load; 140 plugin->load = &gns2dns_load;
135 plugin->store = &gns2dns_store; 141 plugin->store = &gns2dns_store;
136 plugin->validate = &gns2dns_validate; 142 plugin->validate = &gns2dns_validate;
diff --git a/src/namestore/plugin_gtk_namestore_leho.c b/src/namestore/plugin_gtk_namestore_leho.c
index 9187c4fd..a7ec9a25 100644
--- a/src/namestore/plugin_gtk_namestore_leho.c
+++ b/src/namestore/plugin_gtk_namestore_leho.c
@@ -27,8 +27,6 @@
27#include "gnunet_gtk_namestore_plugin.h" 27#include "gnunet_gtk_namestore_plugin.h"
28 28
29 29
30
31
32/** 30/**
33 * The user has edited the LEHO record value. Enable/disable 'save' 31 * The user has edited the LEHO record value. Enable/disable 'save'
34 * button depending on the validity of the value. 32 * button depending on the validity of the value.
@@ -36,13 +34,13 @@
36 * @param entry editing widget 34 * @param entry editing widget
37 * @param user_data the plugin environment 35 * @param user_data the plugin environment
38 */ 36 */
39void 37static void
40GNS_edit_dialog_leho_entry_changed_cb (GtkEditable *entry, 38GNS_edit_dialog_leho_entry_changed_cb (GtkEditable *entry,
41 gpointer user_data) 39 gpointer user_data)
42{ 40{
43 struct GNUNET_GTK_NAMESTORE_PluginEnvironment *env = user_data; 41 struct GNUNET_GTK_NAMESTORE_PluginEnvironment *edc = user_data;
44 42
45 env->check_validity (env->cls); 43 edc->check_validity (edc);
46} 44}
47 45
48 46
@@ -122,7 +120,7 @@ leho_validate (void *cls,
122/** 120/**
123 * Entry point for the plugin. 121 * Entry point for the plugin.
124 * 122 *
125 * @param cls the "struct GNUNET_GTK_NAMESTORE_PluginEnvironment*" 123 * @param cls the `struct GNUNET_GTK_NAMESTORE_PluginEnvironment`
126 * @return NULL on error, otherwise the plugin context 124 * @return NULL on error, otherwise the plugin context
127 */ 125 */
128void * 126void *
@@ -130,11 +128,17 @@ libgnunet_plugin_gtk_namestore_leho_init (void *cls)
130{ 128{
131 struct GNUNET_GTK_NAMESTORE_PluginEnvironment *env = cls; 129 struct GNUNET_GTK_NAMESTORE_PluginEnvironment *env = cls;
132 struct GNUNET_GTK_NAMESTORE_PluginFunctions *plugin; 130 struct GNUNET_GTK_NAMESTORE_PluginFunctions *plugin;
131 static struct GNUNET_GTK_NAMESTORE_Symbol symbols[] = {
132 { "GNS_edit_dialog_leho_entry_changed_cb",
133 G_CALLBACK (GNS_edit_dialog_leho_entry_changed_cb) },
134 { NULL, NULL }
135 };
133 136
134 plugin = GNUNET_new (struct GNUNET_GTK_NAMESTORE_PluginFunctions); 137 plugin = GNUNET_new (struct GNUNET_GTK_NAMESTORE_PluginFunctions);
135 plugin->cls = env; 138 plugin->cls = env;
136 plugin->dialog_glade_filename = "gnunet_namestore_edit_leho.glade"; 139 plugin->dialog_glade_filename = "gnunet_namestore_edit_leho.glade";
137 plugin->dialog_widget_name = "edit_leho_dialog"; 140 plugin->dialog_widget_name = "edit_leho_dialog";
141 plugin->symbols = symbols;
138 plugin->load = &leho_load; 142 plugin->load = &leho_load;
139 plugin->store = &leho_store; 143 plugin->store = &leho_store;
140 plugin->validate = &leho_validate; 144 plugin->validate = &leho_validate;
diff --git a/src/namestore/plugin_gtk_namestore_mx.c b/src/namestore/plugin_gtk_namestore_mx.c
index 34b9df71..d2ce3b15 100644
--- a/src/namestore/plugin_gtk_namestore_mx.c
+++ b/src/namestore/plugin_gtk_namestore_mx.c
@@ -34,13 +34,13 @@
34 * @param entry editing widget 34 * @param entry editing widget
35 * @param user_data the plugin environment 35 * @param user_data the plugin environment
36 */ 36 */
37void 37static void
38GNS_edit_dialog_mx_entry_changed_cb (GtkEditable *entry, 38GNS_edit_dialog_mx_entry_changed_cb (GtkEditable *entry,
39 gpointer user_data) 39 gpointer user_data)
40{ 40{
41 struct GNUNET_GTK_NAMESTORE_PluginEnvironment *env = user_data; 41 struct GNUNET_GTK_NAMESTORE_PluginEnvironment *edc = user_data;
42 42
43 env->check_validity (env->cls); 43 edc->check_validity (edc);
44} 44}
45 45
46 46
@@ -148,7 +148,7 @@ mx_validate (void *cls,
148/**