gnunet-svn
[Top][All Lists]
Advanced

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

[taler-donau] branch master updated: added charity delete


From: gnunet
Subject: [taler-donau] branch master updated: added charity delete
Date: Thu, 18 Jan 2024 13:18:13 +0100

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

johannes-casaburi pushed a commit to branch master
in repository donau.

The following commit(s) were added to refs/heads/master by this push:
     new 56a225b  added charity delete
56a225b is described below

commit 56a225b2575d133ee63fabdef70b80464d618818
Author: Casaburi Johannes <johannes.casaburi@students.bfh.ch>
AuthorDate: Thu Jan 18 13:17:38 2024 +0100

    added charity delete
---
 contrib/gana                                       |  2 +-
 src/donau/Makefile.am                              |  1 +
 src/donau/donau-httpd.c                            |  8 ++
 src/donau/donau-httpd_charity.h                    | 13 ++++
 ..._get-history.c => donau-httpd_charity_delete.c} | 86 +++++++---------------
 src/donau/donau-httpd_get-history.c                |  6 +-
 src/donaudb/Makefile.am                            |  1 +
 src/donaudb/pg_do_charity_delete.c                 | 51 +++++++++++++
 ...{pg_lookup_charity.h => pg_do_charity_delete.h} | 25 ++++---
 src/donaudb/pg_get_history.c                       | 10 +--
 src/donaudb/pg_insert_history_entry.c              |  2 +-
 src/donaudb/pg_insert_history_entry.h              |  2 +-
 src/donaudb/pg_insert_issued_receipt.c             |  2 +-
 src/donaudb/pg_insert_issued_receipt.h             |  2 +-
 src/donaudb/pg_lookup_charity.c                    |  2 +-
 src/donaudb/pg_lookup_charity.h                    |  2 +-
 src/donaudb/plugin_donaudb_postgres.c              | 39 +++++-----
 src/include/donau_service.h                        |  4 +-
 src/include/donaudb_plugin.h                       | 24 ++++--
 src/lib/donau_api_charities_get.c                  | 51 +++++++------
 src/lib/donau_api_charity_get.c                    | 55 +++++++-------
 21 files changed, 226 insertions(+), 162 deletions(-)

diff --git a/contrib/gana b/contrib/gana
index ace673e..8368009 160000
--- a/contrib/gana
+++ b/contrib/gana
@@ -1 +1 @@
-Subproject commit ace673ed30067aa50ef5eebe16cc63ebe1ae066d
+Subproject commit 836800945d80db9c0160a10a84edc1a086339187
diff --git a/src/donau/Makefile.am b/src/donau/Makefile.am
index c3baed9..da7e3d8 100644
--- a/src/donau/Makefile.am
+++ b/src/donau/Makefile.am
@@ -44,6 +44,7 @@ donau_httpd_SOURCES = \
   donau-httpd_keys.c donau-httpd_keys.h \
   donau-httpd_config.c donau-httpd_config.h \
   donau-httpd_get-charities.c donau_httpd_charity.h \
+  donau-httpd_charity_delete.c \
   donau-httpd_get-charity.c donau-httpd_post-charity.c \
   donau-httpd_get-history.c \
   donau-httpd_post-submit-receipt.c donau_httpd_receipt.h \
diff --git a/src/donau/donau-httpd.c b/src/donau/donau-httpd.c
index 11573a6..48e6544 100644
--- a/src/donau/donau-httpd.c
+++ b/src/donau/donau-httpd.c
@@ -482,6 +482,14 @@ handle_mhd_request (void *cls,
       .method = MHD_HTTP_METHOD_POST,
       .handler.post = &DH_handler_charity_post
     },
+    /* DELETE charities */
+    {
+      .url = "charities",
+      .method = MHD_HTTP_METHOD_DELETE,
+      .handler.delete = &DH_handler_charity_delete,
+      .nargs = 1,
+      .nargs_is_upper_bound = true
+    },
     /**
     etc
 
diff --git a/src/donau/donau-httpd_charity.h b/src/donau/donau-httpd_charity.h
index c815761..abf33c8 100644
--- a/src/donau/donau-httpd_charity.h
+++ b/src/donau/donau-httpd_charity.h
@@ -23,6 +23,7 @@
 
 #include <microhttpd.h>
 #include "donau-httpd.h"
+#include "donaudb_plugin.h"
 
 
 /**
@@ -63,4 +64,16 @@ MHD_RESULT
 DH_handler_charities_get (
   struct DH_RequestContext *rc);
 
+/**
+ * Handle a DELETE "/charity/$CHARITY_ID" request.
+ *
+ * @param rc request details about the request to handle
+ * @param args argument with the public key of the purse
+ * @return MHD result code
+ */
+MHD_RESULT
+DH_handler_charity_delete (
+  struct DH_RequestContext *rc,
+  const char *const args[1]);
+
 #endif
diff --git a/src/donau/donau-httpd_get-history.c 
b/src/donau/donau-httpd_charity_delete.c
similarity index 52%
copy from src/donau/donau-httpd_get-history.c
copy to src/donau/donau-httpd_charity_delete.c
index 8ee6365..27ea928 100644
--- a/src/donau/donau-httpd_get-history.c
+++ b/src/donau/donau-httpd_charity_delete.c
@@ -14,85 +14,57 @@
   TALER; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
 */
 /**
- * @file donau-httpd_get-history.c
- * @brief Return history
+ * @file donau-httpd_charity_delete.c
+ * @brief Handle DELETE /charitys/$PID requests; parses the request and
+ *        verifies the signature before handing deletion to the database.
  * @author Johannes Casaburi
  */
 #include "taler/platform.h"
 #include <gnunet/gnunet_util_lib.h>
+#include <gnunet/gnunet_json_lib.h>
 #include <jansson.h>
 #include <microhttpd.h>
+#include "taler/taler_dbevents.h"
 #include "taler/taler_json_lib.h"
 #include "taler/taler_mhd_lib.h"
-#include "taler/taler_signatures.h"
-#include "donau-httpd.h"
-#include "donaudb_plugin.h"
-#include "donau-httpd_history.h"
-// #include "taler-exchange-httpd_metrics.h"
-
-
-/**
- * Maximum number of history we return per request.
- */
-#define MAX_RECORDS 1024
-
-/**
- * Return history information.
- *
- * @param cls closure
- */
-static void
-history_cb (
-  void *cls,
-  uint64_t charity_id,
-  struct TALER_Amount final_amount,
-  uint64_t donation_year)
-{
-  json_t *history = cls;
-
-  GNUNET_assert (
-    0 ==
-    json_array_append (
-      history,
-      GNUNET_JSON_PACK (
-        GNUNET_JSON_pack_int64 ("charity_id",
-                                charity_id),
-        TALER_JSON_pack_amount ("final_amount",
-                                &final_amount),
-        GNUNET_JSON_pack_int64 ("donation_year",
-                                donation_year))));
-}
+// #include "donau-httpd_common_deposit.h"
+#include "donau-httpd_charity.h"
+// #include "donau-httpd_responses.h"
+// #include "taler_exchangedb_lib.h"
+// #include "donau-httpd_keys.h"
 
 
 MHD_RESULT
-DH_handler_history_get (
+DH_handler_charity_delete (
   struct DH_RequestContext *rc,
-  const char *const args[])
+  const char *const args[1])
 {
+  unsigned long long charity_id;
+  char dummy;
 
-  if (NULL != args[1])
+  if ( (NULL == args[0]) ||
+       (1 != sscanf (args[0],
+                     "%llu%c",
+                     &charity_id,
+                     &dummy)) )
   {
     GNUNET_break_op (0);
     return TALER_MHD_reply_with_error (rc->connection,
                                        MHD_HTTP_BAD_REQUEST,
-                                       TALER_EC_GENERIC_ENDPOINT_UNKNOWN,
-                                       args[1]);
+                                       TALER_EC_GENERIC_PARAMETER_MALFORMED,
+                                       "charity_id");
   }
 
   {
-    json_t *history;
     enum GNUNET_DB_QueryStatus qs;
 
-    history = json_array ();
-    GNUNET_assert (NULL != history);
-    qs = DH_plugin->get_history (DH_plugin->cls,
-                                   &history_cb,
-                                   history);
+    qs = DH_plugin->do_charity_delete (DH_plugin->cls,
+                                       charity_id);
     switch (qs)
     {
     case GNUNET_DB_STATUS_HARD_ERROR:
+    case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT:
     case GNUNET_DB_STATUS_SOFT_ERROR:
-      json_decref (history);
       GNUNET_break (0);
       return TALER_MHD_reply_with_error (rc->connection,
                                          MHD_HTTP_INTERNAL_SERVER_ERROR,
@@ -105,16 +77,10 @@ DH_handler_history_get (
         NULL,
         NULL,
         0);
-    case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT:
-      break;
     }
-    return TALER_MHD_REPLY_JSON_PACK (
-      rc->connection,
-      MHD_HTTP_OK,
-      GNUNET_JSON_pack_array_steal ("history",
-                                    history));
   }
+
 }
 
 
-/* end of donau-httpd_get-history.c */
+/* end of donau-httpd_charity_delete.c */
diff --git a/src/donau/donau-httpd_get-history.c 
b/src/donau/donau-httpd_get-history.c
index 8ee6365..b911ca8 100644
--- a/src/donau/donau-httpd_get-history.c
+++ b/src/donau/donau-httpd_get-history.c
@@ -44,7 +44,7 @@
 static void
 history_cb (
   void *cls,
-  uint64_t charity_id,
+  unsigned long long charity_id,
   struct TALER_Amount final_amount,
   uint64_t donation_year)
 {
@@ -86,8 +86,8 @@ DH_handler_history_get (
     history = json_array ();
     GNUNET_assert (NULL != history);
     qs = DH_plugin->get_history (DH_plugin->cls,
-                                   &history_cb,
-                                   history);
+                                 &history_cb,
+                                 history);
     switch (qs)
     {
     case GNUNET_DB_STATUS_HARD_ERROR:
diff --git a/src/donaudb/Makefile.am b/src/donaudb/Makefile.am
index f9acd07..2ab85ac 100644
--- a/src/donaudb/Makefile.am
+++ b/src/donaudb/Makefile.am
@@ -86,6 +86,7 @@ libtaler_plugin_donaudb_postgres_la_SOURCES = \
   pg_get_history.h pg_get_history.c \
   pg_get_charities.h pg_get_charities.c \
   pg_insert_charity.h pg_insert_charity.c \
+  pg_do_charity_delete.h pg_do_charity_delete.c \
   pg_lookup_charity.h pg_lookup_charity.c \
   pg_insert_history_entry.h pg_insert_history_entry.c \
   pg_insert_issued_receipt.h pg_insert_issued_receipt.c \
diff --git a/src/donaudb/pg_do_charity_delete.c 
b/src/donaudb/pg_do_charity_delete.c
new file mode 100644
index 0000000..2ee171e
--- /dev/null
+++ b/src/donaudb/pg_do_charity_delete.c
@@ -0,0 +1,51 @@
+/*
+   This file is part of TALER
+   Copyright (C) 2024 Taler Systems SA
+
+   TALER is free software; you can redistribute it and/or modify it under the
+   terms of the GNU General Public License as published by the Free Software
+   Foundation; either version 3, or (at your option) any later version.
+
+   TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+   WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 
FOR
+   A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License along with
+   TALER; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
+ */
+/**
+ * @file exchangedb/pg_do_charity_delete.c
+ * @brief Implementation of the do_charity_delete function for Postgres
+ * @author Johannes Casaburi
+ */
+#include "taler/platform.h"
+#include "taler/taler_error_codes.h"
+#include "taler/taler_dbevents.h"
+#include "taler/taler_pq_lib.h"
+#include "pg_do_charity_delete.h"
+#include "pg_helper.h"
+
+
+enum GNUNET_DB_QueryStatus
+DH_PG_do_charity_delete (
+  void *cls,
+  unsigned long long charity_id)
+{
+  struct PostgresClosure *pg = cls;
+  struct GNUNET_PQ_QueryParam params[] = {
+    GNUNET_PQ_query_param_uint64 (&charity_id),
+    GNUNET_PQ_query_param_end
+  };
+  struct GNUNET_PQ_ResultSpec rs[] = {
+    GNUNET_PQ_result_spec_end
+  };
+
+  PREPARE (pg,
+           "call_charity_delete",
+           "DELETE FROM charities "
+           "WHERE charity_id=$1");
+  return GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
+                                                   "call_charity_delete",
+                                                   params,
+                                                   rs);
+}
diff --git a/src/donaudb/pg_lookup_charity.h 
b/src/donaudb/pg_do_charity_delete.h
similarity index 61%
copy from src/donaudb/pg_lookup_charity.h
copy to src/donaudb/pg_do_charity_delete.h
index 8dec3c1..d5eeb55 100644
--- a/src/donaudb/pg_lookup_charity.h
+++ b/src/donaudb/pg_do_charity_delete.h
@@ -7,34 +7,35 @@
    Foundation; either version 3, or (at your option) any later version.
 
    TALER is distributed in the hope that it will be useful, but WITHOUT ANY
-   WARRANTY; without even the implied warranty of CHARITYABILITY or FITNESS FOR
+   WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 
FOR
    A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
 
    You should have received a copy of the GNU General Public License along with
    TALER; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
  */
 /**
- * @file donaudb/pg_lookup_charity.h
- * @brief implementation of the lookup_charity function for Postgres
+ * @file exchangedb/pg_do_charity_delete.h
+ * @brief implementation of the do_charity_delete function for Postgres
  * @author Johannes Casaburi
  */
-#ifndef PG_GET_DONATION_UNIT_INFO_H
-#define PG_GET_DONATION_UNIT_INFO_H
+#ifndef PG_DO_PURSE_DELETE_H
+#define PG_DO_PURSE_DELETE_H
 
-#include <taler/taler_util.h>
-#include <taler/taler_json_lib.h>
+#include "taler/taler_util.h"
+#include "taler/taler_json_lib.h"
 #include "donaudb_plugin.h"
+
+
 /**
- * Fetch information about a donation unit key.
+ * Function called to explicitly delete a charity.
  *
  * @param cls the @e cls of this struct with the plugin-specific state
- * @param[out] info information with value and other info about the coin
+ * @param charity_id charity to delete
  * @return transaction status code
  */
 enum GNUNET_DB_QueryStatus
-DH_PG_lookup_charity (
+DH_PG_do_charity_delete (
   void *cls,
-  uint64_t charity_id,
-  struct DONAUDB_CharityMetaData *meta);
+  unsigned long long charity_id);
 
 #endif
diff --git a/src/donaudb/pg_get_history.c b/src/donaudb/pg_get_history.c
index 9606e3f..257ee0f 100644
--- a/src/donaudb/pg_get_history.c
+++ b/src/donaudb/pg_get_history.c
@@ -58,14 +58,14 @@ struct GetHistoryContext
  */
 static void
 get_history_cb (void *cls,
-                  PGresult *result,
-                  unsigned int num_results)
+                PGresult *result,
+                unsigned int num_results)
 {
   struct GetHistoryContext *ctx = cls;
 
   for (unsigned int i = 0; i < num_results; i++)
   {
-    uint64_t charity_id;
+    unsigned long long charity_id;
     struct TALER_Amount final_amount;
     uint64_t donation_year;
 
@@ -100,8 +100,8 @@ get_history_cb (void *cls,
 
 enum GNUNET_DB_QueryStatus
 DH_PG_get_history (void *cls,
-                     DONAUDB_GetHistoryCallback cb,
-                     void *cb_cls)
+                   DONAUDB_GetHistoryCallback cb,
+                   void *cb_cls)
 {
   struct PostgresClosure *pg = cls;
   struct GetHistoryContext ctx = {
diff --git a/src/donaudb/pg_insert_history_entry.c 
b/src/donaudb/pg_insert_history_entry.c
index 872f859..2c3bb61 100644
--- a/src/donaudb/pg_insert_history_entry.c
+++ b/src/donaudb/pg_insert_history_entry.c
@@ -27,7 +27,7 @@
 
 enum GNUNET_DB_QueryStatus
 DH_PG_insert_history_entry (void *cls,
-                            const uint64_t charity_id,
+                            const unsigned long long charity_id,
                             const struct TALER_Amount *final_amount,
                             const uint64_t donation_year)
 {
diff --git a/src/donaudb/pg_insert_history_entry.h 
b/src/donaudb/pg_insert_history_entry.h
index 009c4d5..193ae9c 100644
--- a/src/donaudb/pg_insert_history_entry.h
+++ b/src/donaudb/pg_insert_history_entry.h
@@ -36,7 +36,7 @@
  */
 enum GNUNET_DB_QueryStatus
 DH_PG_insert_history_entry (void *cls,
-                            const uint64_t charity_id,
+                            const unsigned long long charity_id,
                             const struct TALER_Amount *final_amount,
                             const uint64_t donation_year);
 
diff --git a/src/donaudb/pg_insert_issued_receipt.c 
b/src/donaudb/pg_insert_issued_receipt.c
index fbcb45a..6b2575f 100644
--- a/src/donaudb/pg_insert_issued_receipt.c
+++ b/src/donaudb/pg_insert_issued_receipt.c
@@ -29,7 +29,7 @@
 enum GNUNET_DB_QueryStatus
 DH_PG_insert_issued_receipt (void *cls,
                              const struct DONAU_CharitySignatureP *charity_sig,
-                             const uint64_t charity_id,
+                             const unsigned long long charity_id,
                              const struct DONAU_DonationReceiptHashP 
*h_receipt,
                              const struct TALER_Amount *amount)
 {
diff --git a/src/donaudb/pg_insert_issued_receipt.h 
b/src/donaudb/pg_insert_issued_receipt.h
index 781f283..0f7f9bf 100644
--- a/src/donaudb/pg_insert_issued_receipt.h
+++ b/src/donaudb/pg_insert_issued_receipt.h
@@ -38,7 +38,7 @@
 enum GNUNET_DB_QueryStatus
 DH_PG_insert_issued_receipt (void *cls,
                              const struct DONAU_CharitySignatureP *charity_sig,
-                             const uint64_t charity_id,
+                             const unsigned long long charity_id,
                              const struct DONAU_DonationReceiptHashP 
*h_receipt,
                              const struct TALER_Amount *amount);
 
diff --git a/src/donaudb/pg_lookup_charity.c b/src/donaudb/pg_lookup_charity.c
index 3ae6167..883adda 100644
--- a/src/donaudb/pg_lookup_charity.c
+++ b/src/donaudb/pg_lookup_charity.c
@@ -28,7 +28,7 @@
 enum GNUNET_DB_QueryStatus
 DH_PG_lookup_charity (
   void *cls,
-  uint64_t charity_id,
+  unsigned long long charity_id,
   struct DONAUDB_CharityMetaData *meta)
 {
   struct PostgresClosure *pg = cls;
diff --git a/src/donaudb/pg_lookup_charity.h b/src/donaudb/pg_lookup_charity.h
index 8dec3c1..745b2a8 100644
--- a/src/donaudb/pg_lookup_charity.h
+++ b/src/donaudb/pg_lookup_charity.h
@@ -34,7 +34,7 @@
 enum GNUNET_DB_QueryStatus
 DH_PG_lookup_charity (
   void *cls,
-  uint64_t charity_id,
+  unsigned long long charity_id,
   struct DONAUDB_CharityMetaData *meta);
 
 #endif
diff --git a/src/donaudb/plugin_donaudb_postgres.c 
b/src/donaudb/plugin_donaudb_postgres.c
index 8444c53..0e81f40 100644
--- a/src/donaudb/plugin_donaudb_postgres.c
+++ b/src/donaudb/plugin_donaudb_postgres.c
@@ -60,6 +60,7 @@
 #include "pg_lookup_charity.h"
 #include "pg_get_charities.h"
 #include "pg_insert_charity.h"
+#include "pg_do_charity_delete.h"
 
 /**
  * Set to 1 to enable Postgres auto_explain module. This will
@@ -76,14 +77,14 @@
  * @param conn SQL connection that was used
  */
 #define BREAK_DB_ERR(result,conn) do {                                  \
-    GNUNET_break (0);                                                   \
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,                                \
-                "Database failure: %s/%s/%s/%s/%s",                     \
-                PQresultErrorField (result, PG_DIAG_MESSAGE_PRIMARY),   \
-                PQresultErrorField (result, PG_DIAG_MESSAGE_DETAIL),    \
-                PQresultErrorMessage (result),                          \
-                PQresStatus (PQresultStatus (result)),                  \
-                PQerrorMessage (conn));                                 \
+          GNUNET_break (0);                                                   \
+          GNUNET_log (GNUNET_ERROR_TYPE_ERROR,                                \
+                      "Database failure: %s/%s/%s/%s/%s",                     \
+                      PQresultErrorField (result, PG_DIAG_MESSAGE_PRIMARY),   \
+                      PQresultErrorField (result, PG_DIAG_MESSAGE_DETAIL),    \
+                      PQresultErrorMessage (result),                          \
+                      PQresStatus (PQresultStatus (result)),                  \
+                      PQerrorMessage (conn));                                 \
 } while (0)
 
 
@@ -275,35 +276,37 @@ libtaler_plugin_donaudb_postgres_init (void *cls)
     = &DH_PG_event_listen_cancel;
   plugin->event_notify
     = &DH_PG_event_notify;
-  //plugin->get_policy_details
+  // plugin->get_policy_details
   // = &DH_PG_get_policy_details;
-  //plugin->persist_policy_details
+  // plugin->persist_policy_details
   // = &DH_PG_persist_policy_details;
   // plugin->gc
   //  = &DH_PG_gc;
 
   plugin->add_donation_unit_key
-   = &DH_PG_add_donation_unit_key;
+    = &DH_PG_add_donation_unit_key;
   plugin->lookup_donation_unit
-   = &DH_PG_lookup_donation_unit;
+    = &DH_PG_lookup_donation_unit;
   plugin->insert_history_entry
-   = &DH_PG_insert_history_entry;
+    = &DH_PG_insert_history_entry;
   plugin->get_history
-   = &DH_PG_get_history;
+    = &DH_PG_get_history;
   plugin->insert_issued_receipt
-   = &DH_PG_insert_issued_receipt;
+    = &DH_PG_insert_issued_receipt;
   plugin->insert_submitted_receipt
-   = &DH_PG_insert_submitted_receipt;
+    = &DH_PG_insert_submitted_receipt;
   plugin->insert_signing_key
-   = &DH_PG_insert_signing_key;
+    = &DH_PG_insert_signing_key;
   plugin->lookup_signing_key
-   = &DH_PG_lookup_signing_key;
+    = &DH_PG_lookup_signing_key;
   plugin->lookup_charity
     = &DH_PG_lookup_charity;
   plugin->insert_charity
     = &DH_PG_insert_charity;
   plugin->get_charities
     = &DH_PG_get_charities;
+  plugin->do_charity_delete
+    = &DH_PG_do_charity_delete;
 
   return plugin;
 }
diff --git a/src/include/donau_service.h b/src/include/donau_service.h
index 03cc951..1b986d1 100644
--- a/src/include/donau_service.h
+++ b/src/include/donau_service.h
@@ -785,7 +785,7 @@ struct DONAU_CharitySummary
   /**
    * charity id
    */
-  uint64_t charity_id;
+  unsigned long long charity_id;
 
   /**
    * charity name
@@ -1087,7 +1087,7 @@ struct DONAU_PostCharityResponse
       /**
        * charity id
        */
-      uint64_t charity_id;
+      unsigned long long charity_id;
 
 
     } ok;
diff --git a/src/include/donaudb_plugin.h b/src/include/donaudb_plugin.h
index 5365583..97198f3 100644
--- a/src/include/donaudb_plugin.h
+++ b/src/include/donaudb_plugin.h
@@ -199,7 +199,7 @@ typedef void
 typedef void
 (*DONAUDB_GetHistoryCallback)(
   void *cls,
-  uint64_t charity_id,
+  unsigned long long charity_id,
   struct TALER_Amount final_amount,
   uint64_t donation_year);
 
@@ -384,9 +384,23 @@ struct DONAUDB_Plugin
   enum GNUNET_DB_QueryStatus
     (*lookup_charity)(
     void *cls,
-    uint64_t charity_id,
+    unsigned long long charity_id,
     struct DONAUDB_CharityMetaData *meta);
 
+  /**
+   * Delete charity.
+   *
+   * @param cls closure
+   * @param charity_id
+   * @param[out] found set to true if the purse was found
+   *        (if false, purse could not be deleted)
+   * @return database transaction status
+   */
+  enum GNUNET_DB_QueryStatus
+    (*do_charity_delete)(
+    void *cls,
+    unsigned long long charity_id);
+
   /**
    * Get charities.
    *
@@ -458,7 +472,7 @@ struct DONAUDB_Plugin
   enum GNUNET_DB_QueryStatus
     (*lookup_history_entry)(
     void *cls,
-    const uint64_t charity_id,
+    const unsigned long long charity_id,
     const struct TALER_Amount *final_amount,
     const uint64_t donation_year);
 
@@ -502,7 +516,7 @@ struct DONAUDB_Plugin
   enum GNUNET_DB_QueryStatus
     (*insert_history_entry) (
     void *cls,
-    const uint64_t charity_id,
+    const unsigned long long charity_id,
     const struct TALER_Amount *final_amount,
     const uint64_t donation_year);
 
@@ -520,7 +534,7 @@ struct DONAUDB_Plugin
     (*insert_issued_receipt) (
     void *cls,
     const struct DONAU_CharitySignatureP *charity_sig,
-    const uint64_t charity_id,
+    const unsigned long long charity_id,
     const struct DONAU_DonationReceiptHashP *h_receipt,
     const struct TALER_Amount *amount);
 
diff --git a/src/lib/donau_api_charities_get.c 
b/src/lib/donau_api_charities_get.c
index d382fe6..c6544fb 100644
--- a/src/lib/donau_api_charities_get.c
+++ b/src/lib/donau_api_charities_get.c
@@ -52,7 +52,7 @@ struct DONAU_CharitiesGetHandle
   /**
    * Charity id we are querying.
    */
-  uint64_t charity_id;
+  unsigned long long charity_id;
 
   /**
    * Closure to pass to @e cb.
@@ -72,7 +72,7 @@ struct DONAU_CharitiesGetHandle
  */
 static enum GNUNET_GenericReturnValue
 handle_charities_get_ok (const json_t *resp_obj,
-                     struct DONAU_CharityGetHandle *cgh)
+                         struct DONAU_CharityGetHandle *cgh)
 {
   const json_t *charity_hist_array;
   const char *name;
@@ -87,15 +87,16 @@ handle_charities_get_ok (const json_t *resp_obj,
   };
   struct GNUNET_JSON_Specification spec[] = {
     GNUNET_JSON_spec_string ("name",
-                           &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),
+                                
&charity_resp.details.ok.charity->max_per_year),
     TALER_JSON_spec_amount_any ("receipts_to_date",
-                            &charty_resp.details.ok.charity->receipts_to_date),
+                                &charty_resp.details.ok.charity->
+                                receipts_to_date),
     GNUNET_JSON_spec_uint32 ("current_year",
-                              &charity_resp.details.ok.charity->current_year),
+                             &charity_resp.details.ok.charity->current_year),
     GNUNET_JSON_spec_end ()
   };
 
@@ -159,11 +160,11 @@ handle_charities_get_ok (const json_t *resp_obj,
  */
 static void
 handle_charities_get_finished (void *cls,
-                   long response_code,
-                   const void *resp_obj)
+                               long response_code,
+                               const void *resp_obj)
 {
-  //struct DONAU_Charity *cd = NULL;
-  
+  // struct DONAU_Charity *cd = NULL;
+
   struct DONAU_CharityGetHandle *cgh = cls;
   const json_t *j = resp_obj;
   struct DONAU_GetCharityResponse gcresp = {
@@ -180,7 +181,7 @@ handle_charities_get_finished (void *cls,
   case MHD_HTTP_OK:
     if (GNUNET_OK !=
         handle_charity_get_ok (j,
-                                cgh))
+                               cgh))
     {
       gcresp.hr.http_status = 0;
       gcresp.hr.ec = TALER_EC_GENERIC_REPLY_MALFORMED;
@@ -225,12 +226,13 @@ handle_charities_get_finished (void *cls,
   DONAU_charity_get_cancel (cgh);
 }
 
+
 struct DONAU_CharityGetHandle *
 DONAU_charities_get (
   struct GNUNET_CURL_Context *ctx,
   const char *url,
   const uint64_t id,
-  const struct DONAU_BearerToken bearer, //TODO: check authorization
+  const struct DONAU_BearerToken bearer, // TODO: check authorization
   struct GNUNET_TIME_Relative timeout,
   DONAU_GetCharityResponseCallback cb,
   void *cb_cls)
@@ -256,15 +258,15 @@ DONAU_charities_get (
                                        sizeof (id_str));
   *end = '\0';
   GNUNET_snprintf (timeout_str,
-                  sizeof (timeout_str),
-                  "%llu",
-                  (unsigned long long)
-                  (timeout.rel_value_us
-                  / GNUNET_TIME_UNIT_MILLISECONDS.rel_value_us));
+                   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/%s",
-                  id_str);
+                   sizeof (arg_str),
+                   "charities/%s",
+                   id_str);
   cgh->url = TALER_url_join (url,
                              arg_str,
                              NULL);
@@ -285,15 +287,16 @@ DONAU_charities_get (
     return NULL;
   }
   cgh->job = GNUNET_CURL_job_add (ctx,
-                                               eh,
-                                               &handle_charity_get_finished,
-                                               cgh);
+                                  eh,
+                                  &handle_charity_get_finished,
+                                  cgh);
   return cgh;
 }
 
+
 void
 DONAU_charities_get_cancel (
-  struct DONAU_CharityGetHandle *cgh) 
+  struct DONAU_CharityGetHandle *cgh)
 {
   if (NULL != cgh->job)
   {
diff --git a/src/lib/donau_api_charity_get.c b/src/lib/donau_api_charity_get.c
index 26b0042..dabee12 100644
--- a/src/lib/donau_api_charity_get.c
+++ b/src/lib/donau_api_charity_get.c
@@ -52,7 +52,7 @@ struct DONAU_CharityGetHandle
   /**
    * Charity id we are querying.
    */
-  uint64_t charity_id;
+  unsigned long long charity_id;
 
   /**
    * Closure to pass to @e cb.
@@ -72,9 +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)
 {
-  //const json_t *charity_hist_array;
+  // const json_t *charity_hist_array;
   const char *name;
   if (JSON_OBJECT != json_typeof (resp_obj))
   {
@@ -87,15 +87,16 @@ handle_charity_get_ok (const json_t *resp_obj,
   };
   struct GNUNET_JSON_Specification spec[] = {
     GNUNET_JSON_spec_string ("name",
-                           &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),
+                                
&charity_resp.details.ok.charity->max_per_year),
     TALER_JSON_spec_amount_any ("receipts_to_date",
-                            
&charity_resp.details.ok.charity->receipts_to_date),
+                                &charity_resp.details.ok.charity->
+                                receipts_to_date),
     GNUNET_JSON_spec_uint32 ("current_year",
-                              &charity_resp.details.ok.charity->current_year),
+                             &charity_resp.details.ok.charity->current_year),
     GNUNET_JSON_spec_end ()
   };
   if (GNUNET_OK !=
@@ -139,7 +140,7 @@ handle_charity_get_ok (const json_t *resp_obj,
   //       return GNUNET_SYSERR;
   //     }
   //   }
-  //}
+  // }
 
   cgh->cb (cgh->cb_cls,
            &charity_resp);
@@ -158,11 +159,11 @@ handle_charity_get_ok (const json_t *resp_obj,
  */
 static void
 handle_charity_get_finished (void *cls,
-                   long response_code,
-                   const void *resp_obj)
+                             long response_code,
+                             const void *resp_obj)
 {
-  //struct DONAU_Charity *cd = NULL;
-  
+  // struct DONAU_Charity *cd = NULL;
+
   struct DONAU_CharityGetHandle *cgh = cls;
   const json_t *j = resp_obj;
   struct DONAU_GetCharityResponse gcresp = {
@@ -179,7 +180,7 @@ handle_charity_get_finished (void *cls,
   case MHD_HTTP_OK:
     if (GNUNET_OK !=
         handle_charity_get_ok (j,
-                                cgh))
+                               cgh))
     {
       gcresp.hr.http_status = 0;
       gcresp.hr.ec = TALER_EC_GENERIC_REPLY_MALFORMED;
@@ -224,12 +225,13 @@ handle_charity_get_finished (void *cls,
   DONAU_charity_get_cancel (cgh);
 }
 
+
 struct DONAU_CharityGetHandle *
 DONAU_charity_get (
   struct GNUNET_CURL_Context *ctx,
   const char *url,
   const uint64_t id,
-  const struct DONAU_BearerToken bearer, //TODO: check authorization
+  const struct DONAU_BearerToken bearer, // TODO: check authorization
   struct GNUNET_TIME_Relative timeout,
   DONAU_GetCharityResponseCallback cb,
   void *cb_cls)
@@ -255,15 +257,15 @@ DONAU_charity_get (
                                        sizeof (id_str));
   *end = '\0';
   GNUNET_snprintf (timeout_str,
-                  sizeof (timeout_str),
-                  "%llu",
-                  (unsigned long long)
-                  (timeout.rel_value_us
-                  / GNUNET_TIME_UNIT_MILLISECONDS.rel_value_us));
+                   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/%s",
-                  id_str);
+                   sizeof (arg_str),
+                   "charities/%s",
+                   id_str);
   cgh->url = TALER_url_join (url,
                              arg_str,
                              NULL);
@@ -284,15 +286,16 @@ DONAU_charity_get (
     return NULL;
   }
   cgh->job = GNUNET_CURL_job_add (ctx,
-                                               eh,
-                                               &handle_charity_get_finished,
-                                               cgh);
+                                  eh,
+                                  &handle_charity_get_finished,
+                                  cgh);
   return cgh;
 }
 
+
 void
 DONAU_charity_get_cancel (
-  struct DONAU_CharityGetHandle *cgh) 
+  struct DONAU_CharityGetHandle *cgh)
 {
   if (NULL != cgh->job)
   {

-- 
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]