aboutsummaryrefslogtreecommitdiff
path: root/src/reclaim
diff options
context:
space:
mode:
authorSchanzenbach, Martin <mschanzenbach@posteo.de>2020-02-06 20:08:58 +0100
committerSchanzenbach, Martin <mschanzenbach@posteo.de>2020-02-09 20:38:11 +0100
commita80090ffcc10a2a2c188313e997d16802f2777f1 (patch)
treee6485537f1281db4ba3f067c3f2a4f4297dda846 /src/reclaim
parent02daf09b5348ffa894621f59ba0d3497a74ff669 (diff)
downloadgnunet-a80090ffcc10a2a2c188313e997d16802f2777f1.tar.gz
gnunet-a80090ffcc10a2a2c188313e997d16802f2777f1.zip
more bugfixes and REST API change
Diffstat (limited to 'src/reclaim')
-rw-r--r--src/reclaim/plugin_rest_reclaim.c58
1 files changed, 34 insertions, 24 deletions
diff --git a/src/reclaim/plugin_rest_reclaim.c b/src/reclaim/plugin_rest_reclaim.c
index cd163e8a4..417e594fe 100644
--- a/src/reclaim/plugin_rest_reclaim.c
+++ b/src/reclaim/plugin_rest_reclaim.c
@@ -407,6 +407,7 @@ collect_finished_cb (void *cls)
407 407
408 // Done 408 // Done
409 handle->attr_it = NULL; 409 handle->attr_it = NULL;
410 handle->attest_it = NULL;
410 handle->ticket_it = NULL; 411 handle->ticket_it = NULL;
411 GNUNET_SCHEDULER_add_now (&return_response, handle); 412 GNUNET_SCHEDULER_add_now (&return_response, handle);
412} 413}
@@ -624,46 +625,55 @@ attest_collect (void *cls,
624 const struct GNUNET_RECLAIM_AttributeList *attrs) 625 const struct GNUNET_RECLAIM_AttributeList *attrs)
625{ 626{
626 struct RequestHandle *handle = cls; 627 struct RequestHandle *handle = cls;
628 struct GNUNET_RECLAIM_AttributeListEntry *ale;
627 json_t *attr_obj; 629 json_t *attr_obj;
630 json_t *attest_obj;
628 const char *type; 631 const char *type;
629 char *tmp_value; 632 char *tmp_value;
630 char *id_str; 633 char *id_str;
631 634
632 635
633 if (NULL == attest)
634 {
635 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
636 "Attestation Collection with empty Attestation\n");
637 GNUNET_RECLAIM_get_attributes_next (handle->attr_it);
638 return;
639 }
640
641 if ((NULL == attest->name) || (NULL == attest->data))
642 {
643 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
644 "Attestation Collection with empty Name/Value\n");
645 GNUNET_RECLAIM_get_attributes_next (handle->attr_it);
646 return;
647 }
648
649 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attestation: %s\n", 636 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attestation: %s\n",
650 attest->name); 637 attest->name);
651 638
652 tmp_value = GNUNET_RECLAIM_attestation_value_to_string (attest->type, 639 tmp_value = GNUNET_RECLAIM_attestation_value_to_string (attest->type,
653 attest->data, 640 attest->data,
654 attest->data_size); 641 attest->data_size);
655 attr_obj = json_object (); 642 attest_obj = json_object ();
656 json_object_set_new (attr_obj, "value", json_string (tmp_value)); 643 json_object_set_new (attest_obj, "value", json_string (tmp_value));
657 json_object_set_new (attr_obj, "name", json_string (attest->name)); 644 json_object_set_new (attest_obj, "name", json_string (attest->name));
658 type = GNUNET_RECLAIM_attestation_number_to_typename (attest->type); 645 type = GNUNET_RECLAIM_attestation_number_to_typename (attest->type);
659 json_object_set_new (attr_obj, "type", json_string (type)); 646 json_object_set_new (attest_obj, "type", json_string (type));
660 id_str = GNUNET_STRINGS_data_to_string_alloc (&attest->id, 647 id_str = GNUNET_STRINGS_data_to_string_alloc (&attest->id,
661 sizeof(attest->id)); 648 sizeof(attest->id));
662 json_object_set_new (attr_obj, "id", json_string (id_str)); 649 json_object_set_new (attest_obj, "id", json_string (id_str));
663 json_array_append (handle->resp_object, attr_obj);
664 json_decref (attr_obj);
665 GNUNET_free (tmp_value); 650 GNUNET_free (tmp_value);
666 GNUNET_RECLAIM_get_attributes_next (handle->attr_it); 651 if (NULL != attrs)
652 {
653 json_t *attr_arr = json_array ();
654 for (ale = attrs->list_head; NULL != ale; ale = ale->next)
655 {
656 tmp_value =
657 GNUNET_RECLAIM_attribute_value_to_string (ale->attribute->type,
658 ale->attribute->data,
659 ale->attribute->data_size);
660 attr_obj = json_object ();
661 json_object_set_new (attr_obj, "value", json_string (tmp_value));
662 json_object_set_new (attr_obj, "name", json_string (
663 ale->attribute->name));
664
665 json_object_set_new (attr_obj, "flag", json_string ("1")); //FIXME
666 type = GNUNET_RECLAIM_attribute_number_to_typename (ale->attribute->type);
667 json_object_set_new (attr_obj, "type", json_string (type));
668 json_object_set_new (attr_obj, "id", json_string (""));
669 json_object_set_new (attr_obj, "attestation", json_string (""));
670 json_array_append_new (attr_arr, attr_obj);
671 GNUNET_free (tmp_value);
672 }
673 json_object_set_new (attest_obj, "attributes", attr_arr);
674 }
675 json_array_append_new (handle->resp_object, attest_obj);
676 GNUNET_RECLAIM_get_attestations_next (handle->attest_it);
667} 677}
668 678
669 679