diff options
Diffstat (limited to 'src/namestore/plugin_gtk_namestore_gns2dns.c')
-rw-r--r-- | src/namestore/plugin_gtk_namestore_gns2dns.c | 60 |
1 files changed, 48 insertions, 12 deletions
diff --git a/src/namestore/plugin_gtk_namestore_gns2dns.c b/src/namestore/plugin_gtk_namestore_gns2dns.c index 16ac03fb..d5da783c 100644 --- a/src/namestore/plugin_gtk_namestore_gns2dns.c +++ b/src/namestore/plugin_gtk_namestore_gns2dns.c | |||
@@ -56,12 +56,31 @@ GNS_edit_dialog_gns2dns_entry_changed_cb (GtkEditable *entry, | |||
56 | */ | 56 | */ |
57 | static void | 57 | static void |
58 | gns2dns_load (void *cls, | 58 | gns2dns_load (void *cls, |
59 | gchar *n_value, | 59 | gchar *n_value, |
60 | GtkBuilder *builder) | 60 | GtkBuilder *builder) |
61 | { | 61 | { |
62 | char *cpy; | ||
63 | char *at; | ||
64 | |||
65 | cpy = GNUNET_strdup (n_value); | ||
66 | at = strchr (cpy, '@'); | ||
67 | if (NULL == at) | ||
68 | { | ||
69 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
70 | _("Unable to parse GNS2DNS record `%s'\n"), | ||
71 | n_value); | ||
72 | GNUNET_free (cpy); | ||
73 | return; | ||
74 | } | ||
75 | *at = '\0'; | ||
76 | at++; | ||
62 | gtk_entry_set_text (GTK_ENTRY (gtk_builder_get_object (builder, | 77 | gtk_entry_set_text (GTK_ENTRY (gtk_builder_get_object (builder, |
63 | "edit_dialog_gns2dns_entry")), | 78 | "edit_dialog_gns2dns_ns_entry")), |
64 | n_value); | 79 | cpy); |
80 | gtk_entry_set_text (GTK_ENTRY (gtk_builder_get_object (builder, | ||
81 | "edit_dialog_gns2dns_ip_entry")), | ||
82 | at); | ||
83 | GNUNET_free (cpy); | ||
65 | } | 84 | } |
66 | 85 | ||
67 | 86 | ||
@@ -75,15 +94,24 @@ gns2dns_load (void *cls, | |||
75 | */ | 94 | */ |
76 | static gchar * | 95 | static gchar * |
77 | gns2dns_store (void *cls, | 96 | gns2dns_store (void *cls, |
78 | GtkBuilder *builder) | 97 | GtkBuilder *builder) |
79 | { | 98 | { |
80 | GtkEntry *entry; | 99 | GtkEntry *entry; |
81 | const gchar *value; | 100 | const gchar *ns_value; |
101 | const gchar *ip_value; | ||
102 | char *ret; | ||
82 | 103 | ||
83 | entry = GTK_ENTRY (gtk_builder_get_object (builder, | 104 | entry = GTK_ENTRY (gtk_builder_get_object (builder, |
84 | "edit_dialog_gns2dns_entry")); | 105 | "edit_dialog_gns2dns_ns_entry")); |
85 | value = gtk_entry_get_text (entry); | 106 | ns_value = gtk_entry_get_text (entry); |
86 | return g_strdup (value); | 107 | entry = GTK_ENTRY (gtk_builder_get_object (builder, |
108 | "edit_dialog_gns2dns_ip_entry")); | ||
109 | ip_value = gtk_entry_get_text (entry); | ||
110 | GNUNET_asprintf (&ret, | ||
111 | "%s@%s", | ||
112 | ns_value, | ||
113 | ip_value); | ||
114 | return ret; | ||
87 | } | 115 | } |
88 | 116 | ||
89 | 117 | ||
@@ -100,13 +128,19 @@ gns2dns_store (void *cls, | |||
100 | */ | 128 | */ |
101 | static int | 129 | static int |
102 | gns2dns_validate (void *cls, | 130 | gns2dns_validate (void *cls, |
103 | GtkBuilder *builder) | 131 | GtkBuilder *builder) |
104 | { | 132 | { |
105 | GtkEditable *entry; | 133 | GtkEditable *entry; |
106 | const gchar *preedit; | 134 | const gchar *preedit; |
107 | 135 | ||
108 | entry = GTK_EDITABLE (gtk_builder_get_object (builder, | 136 | entry = GTK_EDITABLE (gtk_builder_get_object (builder, |
109 | "edit_dialog_gns2dns_entry")), | 137 | "edit_dialog_gns2dns_ns_entry")), |
138 | preedit = gtk_editable_get_chars (entry, 0, -1); | ||
139 | if ( (NULL == preedit) || | ||
140 | (GNUNET_OK != GNUNET_DNSPARSER_check_name (preedit)) ) | ||
141 | return GNUNET_SYSERR; | ||
142 | entry = GTK_EDITABLE (gtk_builder_get_object (builder, | ||
143 | "edit_dialog_gns2dns_ip_entry")), | ||
110 | preedit = gtk_editable_get_chars (entry, 0, -1); | 144 | preedit = gtk_editable_get_chars (entry, 0, -1); |
111 | if ( (NULL == preedit) || | 145 | if ( (NULL == preedit) || |
112 | (GNUNET_OK != GNUNET_DNSPARSER_check_name (preedit)) ) | 146 | (GNUNET_OK != GNUNET_DNSPARSER_check_name (preedit)) ) |
@@ -127,7 +161,9 @@ libgnunet_plugin_gtk_namestore_gns2dns_init (void *cls) | |||
127 | struct GNUNET_GTK_NAMESTORE_PluginEnvironment *env = cls; | 161 | struct GNUNET_GTK_NAMESTORE_PluginEnvironment *env = cls; |
128 | struct GNUNET_GTK_NAMESTORE_PluginFunctions *plugin; | 162 | struct GNUNET_GTK_NAMESTORE_PluginFunctions *plugin; |
129 | static struct GNUNET_GTK_NAMESTORE_Symbol symbols[] = { | 163 | static struct GNUNET_GTK_NAMESTORE_Symbol symbols[] = { |
130 | { "GNS_edit_dialog_gns2dns_entry_changed_cb", | 164 | { "GNS_edit_dialog_gns2dns_ip_entry_changed_cb", |
165 | G_CALLBACK (GNS_edit_dialog_gns2dns_entry_changed_cb) }, | ||
166 | { "GNS_edit_dialog_gns2dns_ns_entry_changed_cb", | ||
131 | G_CALLBACK (GNS_edit_dialog_gns2dns_entry_changed_cb) }, | 167 | G_CALLBACK (GNS_edit_dialog_gns2dns_entry_changed_cb) }, |
132 | { NULL, NULL } | 168 | { NULL, NULL } |
133 | }; | 169 | }; |