summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-06-03 17:05:24 +0200
committerChristian Grothoff <christian@grothoff.org>2016-06-03 17:05:24 +0200
commit2521aebb798054bf1a1f3511244236339be19280 (patch)
tree8d72752b9eb4bf7b1dea05d1a5f3ceecadbc42b0
parent6ab85b2097891daf6fd3fecc5a1901d4782ebf36 (diff)
downloadmerchant-2521aebb798054bf1a1f3511244236339be19280.tar.gz
merchant-2521aebb798054bf1a1f3511244236339be19280.tar.bz2
merchant-2521aebb798054bf1a1f3511244236339be19280.zip
towards implementing /track
-rw-r--r--src/backend/taler-merchant-httpd_track.c37
-rw-r--r--src/include/taler_merchant_service.h23
2 files changed, 24 insertions, 36 deletions
diff --git a/src/backend/taler-merchant-httpd_track.c b/src/backend/taler-merchant-httpd_track.c
index 54a8b09d..58743231 100644
--- a/src/backend/taler-merchant-httpd_track.c
+++ b/src/backend/taler-merchant-httpd_track.c
@@ -29,6 +29,7 @@
#include "taler-merchant-httpd_auditors.h"
#include "taler-merchant-httpd_exchanges.h"
#include "taler-merchant-httpd_responses.h"
+#include "taler-merchant-httpd_track.h"
extern char *TMH_merchant_currency_string;
@@ -70,6 +71,14 @@ struct DepositTrackContext
*/
unsigned int details_length;
+ struct MHD_Connection *connection;
+
+ unsigned int response_code;
+
+ json_t *json;
+
+ const char *error;
+
};
@@ -104,14 +113,14 @@ wire_deposit_cb (void *cls,
if (NULL == total_amount)
{
rctx->error = "failed to obtain /wire/deposit response from exchange";
- rctx->json = json_incref (json);
+ rctx->json = json_incref ((json_t *) json);
rctx->response_code = http_status;
- MHD_connection_resume (rctx->connection);
+ MHD_resume_connection (rctx->connection);
return;
}
rctx->details_length = details_length;
- rctx->details = GNUNET_new_array (struct TALER_WireDepositDetails,
- details_length);
+ rctx->details = GNUNET_new_array (details_length,
+ struct TALER_WireDepositDetails);
memcpy (rctx->details,
details,
details_length * sizeof (struct TALER_WireDepositDetails));
@@ -141,7 +150,7 @@ cert_cb (void *cls,
{
rctx->error = "failed to obtain /keys from exchange";
rctx->response_code = MHD_HTTP_SERVICE_UNAVAILABLE;
- MHD_connection_resume (rctx->connection);
+ MHD_resume_connection (rctx->connection);
return;
}
rctx->wdh = TALER_EXCHANGE_wire_deposits (rctx->eh,
@@ -177,7 +186,7 @@ MH_handler_track_deposit (struct TMH_RequestHandler *rh,
rctx = *connection_cls;
if (NULL != rctx)
{
- if (NULL == rctx->
+ // ...
}
uri = MHD_lookup_connection_value (connection,
MHD_GET_ARGUMENT_KIND,
@@ -194,15 +203,15 @@ MH_handler_track_deposit (struct TMH_RequestHandler *rh,
if (GNUNET_OK !=
GNUNET_STRINGS_string_to_data (str,
strlen (str),
- &wtid,
- sizeof (wtid)))
+ &rctx->wtid,
+ sizeof (rctx->wtid)))
return TMH_RESPONSE_reply_external_error (connection,
"wtid argument malformed");
- eh = TALER_EXCHANGE_connect (ctx,
- url,
- &cert_cb,
- rctx,
- TALER_EXCHANGE_OPTION_END);
+ rctx->eh = TALER_EXCHANGE_connect (NULL /* FIXME */,
+ uri,
+ &cert_cb,
+ rctx,
+ TALER_EXCHANGE_OPTION_END);
GNUNET_break (0);
return MHD_NO;
@@ -238,7 +247,7 @@ MH_handler_track_transaction (struct TMH_RequestHandler *rh,
if (1 !=
sscanf (str,
"%llu",
- str))
+ &transaction_id))
return TMH_RESPONSE_reply_external_error (connection,
"id argument must be a number");
GNUNET_break (0);
diff --git a/src/include/taler_merchant_service.h b/src/include/taler_merchant_service.h
index d7fd6244..7a22b47c 100644
--- a/src/include/taler_merchant_service.h
+++ b/src/include/taler_merchant_service.h
@@ -60,6 +60,7 @@ TALER_MERCHANT_track_deposit (struct GNUNET_CURL_Context *ctx,
TALER_MERCHANT_TrackDepositCallback trackdeposit_cb,
void *trackdeposit_cb_cls);
+
/**
* Cancel a /track/deposit request. This function cannot be used
* on a request handle if a response is already served for it.
@@ -339,27 +340,5 @@ void
TALER_MERCHANT_pay_cancel (struct TALER_MERCHANT_Pay *ph);
-typedef void
-(*TALER_MERCHANT_TrackDepositCallback)(void *cls,
- ...);
-
-/**
- * Request backend to return deposits associated with a given wtid.
- *
- * @param ctx execution context
- * @param backend_uri URI of the backend
- * @param wtid base32 string indicating a wtid
- * @param exchange_uri base URL of the exchange in charge of returning the wanted information
- * @param trackdeposit_cb the callback to call when a reply for this request is available
- * @param trackdeposit_cb_cls closure for @a contract_cb
- * @return a handle for this request
- */
-struct TALER_MERCHANT_TrackDepositOperation *
-TALER_MERCHANT_track_deposit (struct GNUNET_CURL_Context *ctx,
- const char *backend_uri,
- const char *wtid,
- const char *exchange_uri,
- TALER_MERCHANT_TrackDepositCallback trackdeposit_cb,
- void *trackdeposit_cb_cls);
#endif /* _TALER_MERCHANT_SERVICE_H */