commit 4a01b89bfdc4aa8dd97928a32af5e2252ef79df1
parent abe9d0dcb703baee4bf70dbaf8810c31314cabea
Author: Marcello Stanisci <marcello.stanisci@inria.fr>
Date: Tue, 4 Oct 2016 17:49:29 +0200
still on /history merchant-lib
Diffstat:
2 files changed, 55 insertions(+), 2 deletions(-)
diff --git a/src/include/taler_merchant_service.h b/src/include/taler_merchant_service.h
@@ -508,4 +508,14 @@ TALER_MERCHANT_history (struct GNUNET_CURL_Context *ctx,
TALER_MERCHANT_HistoryOperationCallback history_cb,
void *history_cb_cls);
+
+
+/**
+ * Cancel a pending /history request
+ *
+ * @param handle from the operation to cancel
+ */
+void
+TALER_MERCHANT_history_cancel (struct TALER_MERCHANT_HistoryOperation *handle);
+
#endif /* _TALER_MERCHANT_SERVICE_H */
diff --git a/src/lib/merchant_api_history.c b/src/lib/merchant_api_history.c
@@ -62,6 +62,18 @@ struct TALER_MERCHANT_HistoryOperation
};
/**
+ * Cancel a pending /history request
+ *
+ * @param handle from the operation to cancel
+ */
+void
+TALER_MERCHANT_history_cancel (struct TALER_MERCHANT_HistoryOperation *handle)
+{
+ /*TBD*/
+}
+
+
+/**
* Function called when we're done processing the
* HTTP /track/transaction request.
*
@@ -74,8 +86,39 @@ history_raw_cb (void *cls,
long response_code,
const json_t *json)
{
-
-
+ struct TALER_MERCHANT_HistoryOperation *ho = cls;
+
+ ho->job = NULL;
+
+ switch (response_code)
+ {
+ case 0:
+ break;
+ case MHD_HTTP_OK:
+ ho->cb (ho->cb_cls,
+ response_code,
+ json);
+ break;
+ case MHD_HTTP_INTERNAL_SERVER_ERROR:
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO, "history URI not found\n");
+ break;
+
+ case MHD_HTTP_BAD_REQUEST:
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Wrong parameter passed in URL\n");
+ break;
+ default:
+ /* unexpected response code */
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Unexpected response code %u\n",
+ (unsigned int) response_code);
+ GNUNET_break (0);
+ response_code = 0;
+ break;
+ }
+ ho->cb (ho->cb_cls,
+ response_code,
+ json);
+ TALER_MERCHANT_history_cancel (ho);
}