diff options
author | Christian Grothoff <christian@grothoff.org> | 2014-06-07 13:04:46 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2014-06-07 13:04:46 +0000 |
commit | 14f4d31fc6474997ef9eb2c9b1f439e51ac13728 (patch) | |
tree | 2d1593b296db7b14c1d7716c67bc6aeee4a6fc80 /src/namestore/plugin_gtk_namestore_tlsa.c | |
parent | b0b8c50868496a832f82453b5320522264707c09 (diff) | |
download | gnunet-gtk-14f4d31fc6474997ef9eb2c9b1f439e51ac13728.tar.gz gnunet-gtk-14f4d31fc6474997ef9eb2c9b1f439e51ac13728.zip |
evaluate toggle button logic
Diffstat (limited to 'src/namestore/plugin_gtk_namestore_tlsa.c')
-rw-r--r-- | src/namestore/plugin_gtk_namestore_tlsa.c | 80 |
1 files changed, 76 insertions, 4 deletions
diff --git a/src/namestore/plugin_gtk_namestore_tlsa.c b/src/namestore/plugin_gtk_namestore_tlsa.c index 4fa6ed2c..b0bd6b04 100644 --- a/src/namestore/plugin_gtk_namestore_tlsa.c +++ b/src/namestore/plugin_gtk_namestore_tlsa.c | |||
@@ -73,6 +73,67 @@ edit_dialog_protocol_combobox_changed_cb (GtkEditable *entry, | |||
73 | 73 | ||
74 | 74 | ||
75 | /** | 75 | /** |
76 | * Return the selected button from a list of radio buttons. | ||
77 | * | ||
78 | * @param builder builder to resolve button names | ||
79 | * @param button_names NULL-terminated array of buttons | ||
80 | * @return index of the selected button, -1 for none | ||
81 | */ | ||
82 | static int | ||
83 | get_selected_radio_value (GtkBuilder *builder, | ||
84 | const char *const*button_names) | ||
85 | { | ||
86 | GtkToggleButton *b; | ||
87 | int i; | ||
88 | |||
89 | for (i=0; NULL != button_names[i]; i++) | ||
90 | { | ||
91 | b = GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder, | ||
92 | button_names[i])); | ||
93 | if (gtk_toggle_button_get_active (b)) | ||
94 | return i; | ||
95 | } | ||
96 | return -1; | ||
97 | } | ||
98 | |||
99 | |||
100 | /** | ||
101 | * NULL-terminated array with the names of the "usage" buttons, | ||
102 | * in order to match the respective value in TLSA. | ||
103 | */ | ||
104 | static const char *const usage_buttons[] = { | ||
105 | "edit_dialog_tlsa_usage_ca_radiobutton", | ||
106 | "edit_dialog_tlsa_usage_service_cert_radiobutton", | ||
107 | "edit_dialog_tlsa_usage_trust_anchor_radiobutton", | ||
108 | "edit_dialog_tlsa_usage_domain_issued_cert_radiobutton", | ||
109 | NULL | ||
110 | }; | ||
111 | |||
112 | |||
113 | /** | ||
114 | * NULL-terminated array with the names of the "selector" buttons, | ||
115 | * in order to match the respective value in TLSA. | ||
116 | */ | ||
117 | static const char *const selector_buttons[] = { | ||
118 | "edit_dialog_tlsa_selector_full_cert_radiobutton", | ||
119 | "edit_dialog_tlsa_selector_subject_public_key_radiobutton", | ||
120 | NULL | ||
121 | }; | ||
122 | |||
123 | |||
124 | /** | ||
125 | * NULL-terminated array with the names of the "matching type" buttons, | ||
126 | * in order to match the respective value in TLSA. | ||
127 | */ | ||
128 | static const char *const matching_type_buttons[] = { | ||
129 | "edit_dialog_tlsa_matching_type_full_contents_radiobutton", | ||
130 | "edit_dialog_tlsa_matching_type_sha256_radiobutton", | ||
131 | "edit_dialog_tlsa_matching_type_sha512_radiobutton", | ||
132 | NULL | ||
133 | }; | ||
134 | |||
135 | |||
136 | /** | ||
76 | * Function that will be called to initialize the builder's | 137 | * Function that will be called to initialize the builder's |
77 | * widgets from the existing record (if there is one). | 138 | * widgets from the existing record (if there is one). |
78 | * The `n_value` is the existing value of the record as a string. | 139 | * The `n_value` is the existing value of the record as a string. |
@@ -274,9 +335,19 @@ tlsa_store (void *cls, | |||
274 | &iter, | 335 | &iter, |
275 | 1, &service, | 336 | 1, &service, |
276 | -1); | 337 | -1); |
277 | usage = 42; // FIXME: get from GUI! | 338 | usage = get_selected_radio_value (builder, |
278 | selector = 42; // FIXME: get from GUI! | 339 | usage_buttons); |
279 | matching_type = 42; // FIXME: get from GUI! | 340 | selector = get_selected_radio_value (builder, |
341 | selector_buttons); | ||
342 | matching_type = get_selected_radio_value (builder, | ||
343 | matching_type_buttons); | ||
344 | if ( (-1 == usage) || | ||
345 | (-1 == selector) || | ||
346 | (-1 == matching_type) ) | ||
347 | { | ||
348 | GNUNET_break (0); | ||
349 | return NULL; | ||
350 | } | ||
280 | 351 | ||
281 | tb = gtk_text_view_get_buffer (GTK_TEXT_VIEW | 352 | tb = gtk_text_view_get_buffer (GTK_TEXT_VIEW |
282 | (gtk_builder_get_object (builder, | 353 | (gtk_builder_get_object (builder, |
@@ -363,7 +434,8 @@ tlsa_validate (void *cls, | |||
363 | /* not hex */ | 434 | /* not hex */ |
364 | return GNUNET_SYSERR; | 435 | return GNUNET_SYSERR; |
365 | } | 436 | } |
366 | matching_type = 42; // FIXME: get from GUI! | 437 | matching_type = get_selected_radio_value (builder, |
438 | matching_type_buttons); | ||
367 | 439 | ||
368 | switch (matching_type) | 440 | switch (matching_type) |
369 | { | 441 | { |