gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-donau] branch master updated (d686cb0 -> 7dc8c45)


From: gnunet
Subject: [taler-donau] branch master updated (d686cb0 -> 7dc8c45)
Date: Tue, 27 Feb 2024 11:57:14 +0100

This is an automated email from the git hooks/post-receive script.

lukas-matyja pushed a change to branch master
in repository donau.

    from d686cb0  some changes
     new 0faf3be  some changes
     new 7dc8c45  [lib] work on charity get

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/include/donau_service.h               |  8 +--
 src/lib/donau_api_charity_get.c           | 87 ++++++++++++++++---------------
 src/lib/donau_api_handle.c                |  8 +--
 src/testing/testing_api_cmd_charity_get.c |  4 +-
 4 files changed, 55 insertions(+), 52 deletions(-)

diff --git a/src/include/donau_service.h b/src/include/donau_service.h
index 9a22129..f3811af 100644
--- a/src/include/donau_service.h
+++ b/src/include/donau_service.h
@@ -838,7 +838,7 @@ struct DONAU_GetCharitiesResponse
       /**
        * Charity status information.
        */
-      struct DONAU_CharitySummary *charity;
+      struct DONAU_CharitySummary charity;
 
       /**
        * Number of charities
@@ -916,7 +916,7 @@ struct DONAU_Charity
   /**
    * public key of the charity
    */
-  struct DONAU_CharitySignatureP charity_pub;
+  struct DONAU_CharityPublicKeyP charity_pub;
 
   /**
     * Max donation amout for this charitiy and @e current_year.
@@ -931,7 +931,7 @@ struct DONAU_Charity
   /**
    * current year
    */
-  uint32_t current_year;
+  uint64_t current_year;
 
 };
 
@@ -1290,4 +1290,4 @@ void
 DONAU_charity_post_delete (
   struct DONAU_CharityDeleteHandle *rgh);
 
-#endif
\ No newline at end of file
+#endif
diff --git a/src/lib/donau_api_charity_get.c b/src/lib/donau_api_charity_get.c
index dba71b2..2ccc7ab 100644
--- a/src/lib/donau_api_charity_get.c
+++ b/src/lib/donau_api_charity_get.c
@@ -72,7 +72,9 @@ struct DONAU_CharityGetHandle
  */
 static enum GNUNET_GenericReturnValue
 handle_charity_get_ok (const json_t *resp_obj,
-                       struct DONAU_CharityGetHandle *cgh)
+                       struct DONAU_CharityGetHandle *cgh,
+                                          struct DONAU_Charity *charity,
+                                          struct DONAU_GetCharityResponse 
*gcresp)
 {
   // const json_t *charity_hist_array;
   const char *name;
@@ -81,22 +83,18 @@ handle_charity_get_ok (const json_t *resp_obj,
     GNUNET_break_op (0);
     return GNUNET_SYSERR;
   }
-  struct DONAU_GetCharityResponse charity_resp = {
-    .hr.reply = resp_obj,
-    .hr.http_status = MHD_HTTP_OK
-  };
+
   struct GNUNET_JSON_Specification spec[] = {
-    GNUNET_JSON_spec_string ("name",
-                             &name),
-    GNUNET_JSON_spec_fixed_auto ("charity_pub",
-                                 
&charity_resp.details.ok.charity->charity_pub),
-    TALER_JSON_spec_amount_any ("max_per_year",
-                                
&charity_resp.details.ok.charity->max_per_year),
-    TALER_JSON_spec_amount_any ("receipts_to_date",
-                                &charity_resp.details.ok.charity->
-                                receipts_to_date),
-    GNUNET_JSON_spec_uint32 ("current_year",
-                             &charity_resp.details.ok.charity->current_year),
+//    GNUNET_JSON_spec_fixed_auto ("charity_pub",
+//                                 &charity->charity_pub),
+//     GNUNET_JSON_spec_string ("name", &name),
+//    TALER_JSON_spec_amount_any ("max_per_year",
+//                                &charity->max_per_year),
+//    TALER_JSON_spec_amount_any ("receipts_to_date",
+//                                &charity->
+//                                receipts_to_date),
+//    GNUNET_JSON_spec_uint64 ("current_year",
+//                             &charity->current_year),
     GNUNET_JSON_spec_end ()
   };
   if (GNUNET_OK !=
@@ -108,7 +106,7 @@ handle_charity_get_ok (const json_t *resp_obj,
     GNUNET_break_op (0);
     return GNUNET_SYSERR;
   }
-  charity_resp.details.ok.charity->name = GNUNET_strdup (name);
+  //charity->name = GNUNET_strdup (name);
 
   /* parse the charity history data */
   // charity_resp.details.ok.charity->num_hist
@@ -143,7 +141,7 @@ handle_charity_get_ok (const json_t *resp_obj,
   // }
 
   cgh->cb (cgh->cb_cls,
-           &charity_resp);
+           gcresp);
   cgh->cb = NULL;
   return GNUNET_OK;
 }
@@ -180,7 +178,9 @@ handle_charity_get_finished (void *cls,
   case MHD_HTTP_OK:
     if (GNUNET_OK !=
         handle_charity_get_ok (j,
-                               cgh))
+                               cgh,
+                                                          
&gcresp.details.ok.charity,
+                                                          &gcresp))
     {
       gcresp.hr.http_status = 0;
       gcresp.hr.ec = TALER_EC_GENERIC_REPLY_MALFORMED;
@@ -248,18 +248,26 @@ DONAU_charity_get (
   cgh->cb_cls = cb_cls;
   char arg_str[sizeof (id) * 2 + 32];
   char timeout_str[32];
-
+  unsigned int tms
+    = (unsigned int) timeout.rel_value_us
+      / GNUNET_TIME_UNIT_MILLISECONDS.rel_value_us;
   GNUNET_snprintf (timeout_str,
-                   sizeof (timeout_str),
-                   "%llu",
-                   (unsigned long long)
-                   (timeout.rel_value_us
-                    / GNUNET_TIME_UNIT_MILLISECONDS.rel_value_us));
-  GNUNET_snprintf (arg_str,
-                   sizeof (arg_str),
-                   "charities/%llu",
-                                  (unsigned long long)
-                   id);
+                                  sizeof (timeout_str),
+                                  "%u",
+                                  tms);
+  if (tms == 0)
+         GNUNET_snprintf (arg_str,
+                                          sizeof (arg_str),
+                                          "charities/%llu",
+                                          (unsigned long long)
+                                          id);
+  else
+      GNUNET_snprintf (arg_str,
+                       sizeof (arg_str),
+                       "reserves/%llu?timeout_ms=%s",
+                                          (unsigned long long)
+                                          id,
+                       timeout_str);
   cgh->url = TALER_url_join (url,
                              arg_str,
                              NULL);
@@ -279,18 +287,13 @@ DONAU_charity_get (
     GNUNET_free (cgh);
     return NULL;
   }
-  GNUNET_break (CURLE_OK ==
-                curl_easy_setopt (eh,
-                                  CURLOPT_VERBOSE,
-                                  1));
-  GNUNET_break (CURLE_OK ==
-                curl_easy_setopt (eh,
-                                  CURLOPT_TIMEOUT,
-                                  120 /* seconds */));
-  GNUNET_assert (CURLE_OK ==
-                 curl_easy_setopt (eh,
-                                   CURLOPT_HEADERDATA,
-                                   cgh));
+  if (0 != tms)
+  {
+    GNUNET_break (CURLE_OK ==
+                  curl_easy_setopt (eh,
+                                    CURLOPT_TIMEOUT_MS,
+                                    (long) (tms + 100L)));
+  }
   cgh->job = GNUNET_CURL_job_add_with_ct_json (ctx,
                                   eh,
                                   &handle_charity_get_finished,
diff --git a/src/lib/donau_api_handle.c b/src/lib/donau_api_handle.c
index a1c79b0..cc06634 100644
--- a/src/lib/donau_api_handle.c
+++ b/src/lib/donau_api_handle.c
@@ -614,10 +614,10 @@ DONAU_get_keys (
   //                curl_easy_setopt (eh,
   //                                  CURLOPT_HEADERFUNCTION,
   //                                  &header_cb));
-  GNUNET_assert (CURLE_OK ==
-                 curl_easy_setopt (eh,
-                                   CURLOPT_HEADERDATA,
-                                   gkh));
+//  GNUNET_assert (CURLE_OK ==
+//                 curl_easy_setopt (eh,
+//                                   CURLOPT_HEADERDATA,
+//                                   gkh));
   gkh->job = GNUNET_CURL_job_add_with_ct_json (ctx,
                                                eh,
                                                &keys_completed_cb,
diff --git a/src/testing/testing_api_cmd_charity_get.c 
b/src/testing/testing_api_cmd_charity_get.c
index 4aab42f..fede656 100644
--- a/src/testing/testing_api_cmd_charity_get.c
+++ b/src/testing/testing_api_cmd_charity_get.c
@@ -17,7 +17,7 @@
   <http://www.gnu.org/licenses/>
 */
 /**
- * @file testing/testing_api_cmd_reserve_get.c
+ * @file testing/testing_api_cmd_charity_get.c
  * @brief Implement the GET /reserve/$RID test command.
  * @author Marcello Stanisci
  * @author Lukas Matyja
@@ -165,7 +165,7 @@ status_run (void *cls,
   ss->cgh = DONAU_charity_get (
     TALER_TESTING_interpreter_get_context (is),
     donau_url,
-    1,
+    4,
     bearer,
     ss->timeout,
     &charity_status_cb,

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]