commit a0ac860920945b74ce3020ec7bcc7c2181c3cfd7
parent 2db37d200729d7d0e665c6c974fa92349400d84a
Author: Tellenbach Reto <tellr1@bfh.ch>
Date: Mon, 8 Jun 2026 13:44:29 +0200
[dbg] State-logic: Scan QR-code, poll multiple times delayd
Diffstat:
3 files changed, 49 insertions(+), 28 deletions(-)
diff --git a/src/lib/bank_api_get_withdrawals.c b/src/lib/bank_api_get_withdrawals.c
@@ -216,7 +216,7 @@ TALER_BANK_get_withdrawal ( struct GNUNET_CURL_Context *ctx,
const char *wopid,
TALER_BANK_WithdrawalCallback withdrawals_cb,
void *withdrawals_cb_cls,
- const unsigned long timeout_ms)
+ const char *timeout_ms)
{
struct TALER_BANK_GetWithdrawalHandle *withdrawal;
char *url;
@@ -229,7 +229,7 @@ TALER_BANK_get_withdrawal ( struct GNUNET_CURL_Context *ctx,
GNUNET_asprintf(&url,
"withdrawals/%s",
wopid);
- if (0 != timeout_ms)
+ if (NULL != timeout_ms)
{
withdrawal->job_url = TALER_url_join(base_url,
url,
diff --git a/src/lib/bank_api_get_withdrawals.h b/src/lib/bank_api_get_withdrawals.h
@@ -135,8 +135,7 @@ struct TALER_BANK_GetWithdrawalHandle;
* @param wopid withdrawal operation id
* @param withdrawal_cb callback
* @param withdrawal_cb_cls callback context
- * @param timeout_ms timeout to long-polling,
- * ignored when 0, therfor no long-poll
+ * @param timeout_ms timeout to long-polling, ignored when NULL, therfor no long-poll
* @return NULL on failure
*/
struct TALER_BANK_GetWithdrawalHandle *
@@ -145,7 +144,7 @@ TALER_BANK_get_withdrawal ( struct GNUNET_CURL_Context *ctx,
const char *wopid,
TALER_BANK_WithdrawalCallback withdrawals_cb,
void *withdrawals_cb_cls,
- const unsigned long timeout_ms);
+ const char *timeout_ms);
/**
diff --git a/src/taler-digitizer.c b/src/taler-digitizer.c
@@ -32,6 +32,7 @@
#include "lib/bank_api_get_accounts.h"
#include "lib/bank_api_post_accounts_withdrawals.h"
#include "lib/bank_api_get_withdrawals.h"
+#include "lib/bank_api_post_accounts_withdrawals_confirm.h"
#include "digitizer_display.h"
@@ -44,7 +45,7 @@
#define FRAMEBUFFER_SIZE 256
#define PATH_QR_SHOW "/ext/QRshow"
-#define SCAN_QR_TIMEOUT_SECONDS 100
+#define SCAN_QR_TIMEOUT_SECONDS 60
/**
* Global return value
@@ -481,27 +482,52 @@ on_post_accounts_withdrawal_done(void *cls,
return;
}
+/**
+ * Get withdrawal request for repeated requesting
+ */
+static void
+get_withdrawal_task(void *cls);
/**
* callback of accounts withdrawal request
* used in the QR Create state
*/
static void
-on_get_withdrawal_selected_done(void *cls,
+on_get_withdrawal_status_done(void *cls,
const struct TALER_BANK_WithdrawalResponse *vr)
{
TALER_LOG_DEBUG ("Callback of withdrawal/$WITHDRAWAL_ID\n");
-
- (void) cls;
- if(0 != strcasecmp("active", vr->details.ok.acc.status))
+ struct GNUNET_TIME_Relative delay;
+ struct GNUNET_SCHEDULER_Task *timeout_handle;
+ delay = GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS,SCAN_QR_TIMEOUT_SECONDS);
+ timeout_handle = cls;
+ if(0 == strcasecmp("active", vr->details.ok.acc.status))
{
- TALER_LOG_WARNING("QR-code was not scanned in time\n");
- state = DIGITIZER_STATE_CANCEL_WITHDRAWAL;
+ GNUNET_SCHEDULER_cancel(timeout_handle);
+ state = DIGITIZER_STATE_COUNT_MONEY;
+ // give context for non terminal errors!
GNUNET_SCHEDULER_add_now(state_controller_task,NULL);
}
- state = DIGITIZER_STATE_SCAN_QR;
- GNUNET_SCHEDULER_add_now(state_controller_task,NULL);
+ GNUNET_SCHEDULER_add_delayed(delay,get_withdrawal_task,timeout_handle);
+ return;
+}
+
+/**
+ * Get withdrawal request for repeated requesting
+ */
+static void
+get_withdrawal_task(void *cls)
+{
+ struct GNUNET_SCHEDULER_Task *timeout_handle;
+ timeout_handle = cls;
+
+ TALER_BANK_get_withdrawal(curl_ctx,
+ cfg_bank_base_url,
+ state_ctx->wi.withdrawal_id,
+ on_get_withdrawal_status_done,
+ timeout_handle,
+ NULL);
return;
}
@@ -510,9 +536,8 @@ on_get_withdrawal_selected_done(void *cls,
* SCAN_QR_TIMEOUT_SECONDS without been scanned
* used in the ScanQR state
*/
-/*
static void
-ScanQR_timeout(void *cls)
+timeout_task(void *cls)
{
TALER_LOG_DEBUG ("Timeout of ScanQR\n");
@@ -522,7 +547,6 @@ ScanQR_timeout(void *cls)
GNUNET_SCHEDULER_add_now(state_controller_task,NULL);
return;
}
-*/
/**
* @brief Cleanup when no task is scheduled anymore
@@ -1023,8 +1047,12 @@ static void ScanQR_state_task(void *cls)
{
TALER_LOG_DEBUG ("ScanQR state\n");
(void)cls;
- //struct GNUNET_TIME_Relative delay;
- //delay = GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS,SCAN_QR_TIMEOUT_SECONDS);
+
+ struct GNUNET_SCHEDULER_Task *timeout_handle;
+ struct GNUNET_TIME_Relative delay;
+
+ delay = GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS,SCAN_QR_TIMEOUT_SECONDS);
+ timeout_handle = GNUNET_SCHEDULER_add_delayed(delay,timeout_task,NULL);
if(GNUNET_OK != run_qr_show(SCAN_QR_TIMEOUT_SECONDS))
{
TALER_LOG_ERROR("run_qr_show failed\n");
@@ -1032,16 +1060,10 @@ static void ScanQR_state_task(void *cls)
// give context for non terminal errors!
GNUNET_SCHEDULER_add_now(state_controller_task,NULL);
}
+ //char *buf;
+ //GNUNET_asprintf(&buf,"%d",SCAN_QR_TIMEOUT_SECONDS*1000);
- TALER_BANK_get_withdrawal(curl_ctx,
- cfg_bank_base_url,
- state_ctx->wi.withdrawal_id,
- on_get_withdrawal_selected_done,
- NULL,
- SCAN_QR_TIMEOUT_SECONDS);
-
- state = DIGITIZER_STATE_CANCEL_WITHDRAWAL;
- GNUNET_SCHEDULER_add_now(state_controller_task,NULL);
+ GNUNET_SCHEDULER_add_delayed(delay,get_withdrawal_task,timeout_handle);
return;
}