diff options
Diffstat (limited to 'src/anastasis/anastasis-gtk_action.c')
-rw-r--r-- | src/anastasis/anastasis-gtk_action.c | 81 |
1 files changed, 52 insertions, 29 deletions
diff --git a/src/anastasis/anastasis-gtk_action.c b/src/anastasis/anastasis-gtk_action.c index d742a25..be0bf51 100644 --- a/src/anastasis/anastasis-gtk_action.c +++ b/src/anastasis/anastasis-gtk_action.c | |||
@@ -1327,7 +1327,7 @@ action_secret_editing (void) | |||
1327 | } | 1327 | } |
1328 | if (NULL != filename) | 1328 | if (NULL != filename) |
1329 | { | 1329 | { |
1330 | AG_insensitive ("anastasis_gtk_enter_secret_textbuffer"); | 1330 | AG_insensitive ("anastasis_gtk_enter_secret_textview"); |
1331 | AG_show ("anastasis_gtk_secret_clear_file_button"); | 1331 | AG_show ("anastasis_gtk_secret_clear_file_button"); |
1332 | AG_show ("anastasis_gtk_secret_file_name_hbox"); | 1332 | AG_show ("anastasis_gtk_secret_file_name_hbox"); |
1333 | AG_hide ("anastasis_gtk_secret_file_chooser_hbox"); | 1333 | AG_hide ("anastasis_gtk_secret_file_chooser_hbox"); |
@@ -1348,7 +1348,7 @@ action_secret_editing (void) | |||
1348 | (0 == strlen (name) ) ) | 1348 | (0 == strlen (name) ) ) |
1349 | AG_focus ("anastasis_gtk_secret_name_entry"); | 1349 | AG_focus ("anastasis_gtk_secret_name_entry"); |
1350 | else if (NULL == filename) | 1350 | else if (NULL == filename) |
1351 | AG_focus ("anastasis_gtk_enter_secret_textbuffer"); | 1351 | AG_focus ("anastasis_gtk_enter_secret_textview"); |
1352 | GNUNET_JSON_parse_free (spec); | 1352 | GNUNET_JSON_parse_free (spec); |
1353 | } | 1353 | } |
1354 | AG_sensitive ("anastasis_gtk_main_window_prev_button"); | 1354 | AG_sensitive ("anastasis_gtk_main_window_prev_button"); |
@@ -2231,7 +2231,7 @@ challenge_button_clicked_cb (GObject *object, | |||
2231 | static void | 2231 | static void |
2232 | add_challenge (GtkBox *challenge_box, | 2232 | add_challenge (GtkBox *challenge_box, |
2233 | json_t *rd, | 2233 | json_t *rd, |
2234 | json_t *challenge) | 2234 | json_t *uchallenge) |
2235 | { | 2235 | { |
2236 | GtkBuilder *builder; | 2236 | GtkBuilder *builder; |
2237 | GtkWindow *window; | 2237 | GtkWindow *window; |
@@ -2245,6 +2245,12 @@ add_challenge (GtkBox *challenge_box, | |||
2245 | struct TALER_Amount cost; | 2245 | struct TALER_Amount cost; |
2246 | bool async = false; | 2246 | bool async = false; |
2247 | bool solved = false; | 2247 | bool solved = false; |
2248 | struct GNUNET_JSON_Specification uspec[] = { | ||
2249 | GNUNET_JSON_spec_string ("uuid", | ||
2250 | &uuid), | ||
2251 | GNUNET_JSON_spec_end () | ||
2252 | }; | ||
2253 | const char *iuuid; | ||
2248 | struct GNUNET_JSON_Specification spec[] = { | 2254 | struct GNUNET_JSON_Specification spec[] = { |
2249 | GNUNET_JSON_spec_string ("instructions", | 2255 | GNUNET_JSON_spec_string ("instructions", |
2250 | &instructions), | 2256 | &instructions), |
@@ -2253,30 +2259,49 @@ add_challenge (GtkBox *challenge_box, | |||
2253 | GNUNET_JSON_spec_string ("url", | 2259 | GNUNET_JSON_spec_string ("url", |
2254 | &provider), | 2260 | &provider), |
2255 | GNUNET_JSON_spec_string ("uuid", | 2261 | GNUNET_JSON_spec_string ("uuid", |
2256 | &uuid), | 2262 | &iuuid), |
2257 | GNUNET_JSON_spec_mark_optional ( | 2263 | GNUNET_JSON_spec_mark_optional ( |
2258 | GNUNET_JSON_spec_bool ("async", | 2264 | GNUNET_JSON_spec_bool ("async", |
2259 | &async)), | 2265 | &async)), |
2266 | GNUNET_JSON_spec_mark_optional ( | ||
2267 | GNUNET_JSON_spec_bool ("solved", | ||
2268 | &solved)), | ||
2260 | GNUNET_JSON_spec_end () | 2269 | GNUNET_JSON_spec_end () |
2261 | }; | 2270 | }; |
2262 | 2271 | ||
2263 | { | ||
2264 | const json_t *ks; | ||
2265 | |||
2266 | ks = json_object_get (challenge, | ||
2267 | "key_share"); | ||
2268 | if ( (NULL != ks) && | ||
2269 | (! json_is_null (ks)) ) | ||
2270 | solved = true; | ||
2271 | } | ||
2272 | if (GNUNET_OK != | 2272 | if (GNUNET_OK != |
2273 | GNUNET_JSON_parse (challenge, | 2273 | GNUNET_JSON_parse (uchallenge, |
2274 | spec, | 2274 | uspec, |
2275 | NULL, NULL)) | 2275 | NULL, NULL)) |
2276 | { | 2276 | { |
2277 | GNUNET_break (0); | 2277 | GNUNET_break (0); |
2278 | return; | 2278 | return; |
2279 | } | 2279 | } |
2280 | { | ||
2281 | json_t *challenges; | ||
2282 | size_t index; | ||
2283 | json_t *challenge; | ||
2284 | |||
2285 | challenges = json_object_get (rd, | ||
2286 | "cs"); | ||
2287 | /* TODO: change data structure to have 'uuid' | ||
2288 | as the index into the 'challenges' object, instead of this | ||
2289 | 'challenges' being an array */ | ||
2290 | json_array_foreach (challenges, index, challenge) | ||
2291 | { | ||
2292 | if (GNUNET_OK != | ||
2293 | GNUNET_JSON_parse (challenge, | ||
2294 | spec, | ||
2295 | NULL, NULL)) | ||
2296 | { | ||
2297 | GNUNET_break (0); | ||
2298 | continue; | ||
2299 | } | ||
2300 | if (0 == strcmp (uuid, | ||
2301 | iuuid)) | ||
2302 | break; | ||
2303 | } | ||
2304 | } | ||
2280 | if (GNUNET_OK != | 2305 | if (GNUNET_OK != |
2281 | lookup_recovery_cost (provider, | 2306 | lookup_recovery_cost (provider, |
2282 | type, | 2307 | type, |
@@ -2333,13 +2358,12 @@ add_challenge (GtkBox *challenge_box, | |||
2333 | g_object_ref (hbox); | 2358 | g_object_ref (hbox); |
2334 | gtk_container_remove (GTK_CONTAINER (window), | 2359 | gtk_container_remove (GTK_CONTAINER (window), |
2335 | hbox); | 2360 | hbox); |
2336 | g_object_unref (window); | ||
2337 | g_object_unref (builder); | 2361 | g_object_unref (builder); |
2338 | gtk_box_pack_end (challenge_box, | 2362 | gtk_box_pack_start (challenge_box, |
2339 | hbox, | 2363 | hbox, |
2340 | false, | 2364 | false, |
2341 | false, | 2365 | false, |
2342 | 15); | 2366 | 15); |
2343 | } | 2367 | } |
2344 | 2368 | ||
2345 | 2369 | ||
@@ -2397,20 +2421,19 @@ add_policy (GtkBox *policy_box, | |||
2397 | } | 2421 | } |
2398 | GNUNET_asprintf (&txt, | 2422 | GNUNET_asprintf (&txt, |
2399 | _ ("Policy #%u"), | 2423 | _ ("Policy #%u"), |
2400 | (unsigned int) pindex); | 2424 | (unsigned int) 1 + pindex); |
2401 | gtk_label_set_text (label, | 2425 | gtk_label_set_text (label, |
2402 | txt); | 2426 | txt); |
2403 | GNUNET_free (txt); | 2427 | GNUNET_free (txt); |
2404 | g_object_ref (widget); | 2428 | g_object_ref (widget); |
2405 | gtk_container_remove (GTK_CONTAINER (window), | 2429 | gtk_container_remove (GTK_CONTAINER (window), |
2406 | widget); | 2430 | widget); |
2407 | g_object_unref (window); | ||
2408 | g_object_unref (builder); | 2431 | g_object_unref (builder); |
2409 | gtk_box_pack_end (policy_box, | 2432 | gtk_box_pack_start (policy_box, |
2410 | widget, | 2433 | widget, |
2411 | false, | 2434 | false, |
2412 | false, | 2435 | false, |
2413 | 15); | 2436 | 15); |
2414 | } | 2437 | } |
2415 | 2438 | ||
2416 | 2439 | ||
@@ -3366,7 +3389,7 @@ action_challenge_solving (void) | |||
3366 | GtkWidget *box; | 3389 | GtkWidget *box; |
3367 | 3390 | ||
3368 | box = GTK_WIDGET (GCG_get_main_window_object ( | 3391 | box = GTK_WIDGET (GCG_get_main_window_object ( |
3369 | "anastasis_gtk_open_challenge_box")); | 3392 | "anastasis_gtk_policy_vbox")); |
3370 | toplevel = gtk_widget_get_toplevel (box); | 3393 | toplevel = gtk_widget_get_toplevel (box); |
3371 | gtk_window_set_transient_for (GTK_WINDOW (diag), | 3394 | gtk_window_set_transient_for (GTK_WINDOW (diag), |
3372 | GTK_WINDOW (toplevel)); | 3395 | GTK_WINDOW (toplevel)); |