diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/exchange-tools/taler-wire.c | 70 | ||||
-rw-r--r-- | src/include/taler_wire_plugin.h | 50 | ||||
-rw-r--r-- | src/wire-plugins/plugin_wire_taler-bank.c | 22 | ||||
-rw-r--r-- | src/wire-plugins/test_wire_plugin_transactions_taler-bank.c | 7 |
4 files changed, 63 insertions, 86 deletions
diff --git a/src/exchange-tools/taler-wire.c b/src/exchange-tools/taler-wire.c index 213c1eff3..f9c4a3579 100644 --- a/src/exchange-tools/taler-wire.c +++ b/src/exchange-tools/taler-wire.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2014-2018 Taler Systems SA + Copyright (C) 2014--2019 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 @@ -29,62 +29,67 @@ #include "taler_wire_lib.h" /** - * If set to GNUNET_YES, then we'll ask the bank for a list + * If set to #GNUNET_YES, then we'll ask the bank for a list * of transactions from the account mentioned in the config * section. */ -int history; +static int history; /** * If set to GNUNET_YES, then we'll ask the bank to execute a * wire transfer. */ -int transfer; +static int transfer; /** * Name of the wire plugin to use with the bank. */ -char *plugin_name; +static char *plugin_name; /** * Global return code. */ -unsigned int global_ret = 1; +static unsigned int global_ret = 1; /** * When a wire transfer is being performed, this value * specifies the amount to wire-transfer. It's given in * the usual CURRENCY:X[.Y] format. */ -char *amount; +static char *amount; /** * Base32 encoding of a transaction ID. When asking the * bank for a transaction history, all the results will * have a transaction ID settled *after* this one. */ -char *since_when; +static char *since_when; /** * Which config section has the credentials to access the bank. */ -char *account_section; +static char *account_section; /** * URL identifying the account that is going to receive the * wire transfer. */ -char *destination_account_url; +static char *destination_account_url; /** * Handle for the wire transfer preparation task. */ -struct TALER_WIRE_PrepareHandle *ph; +static struct TALER_WIRE_PrepareHandle *ph; /** * Wire plugin handle. */ -struct TALER_WIRE_Plugin *plugin_handle; +static struct TALER_WIRE_Plugin *plugin_handle; + +/** + * Handle to ongoing history operation. + */ +static struct TALER_WIRE_HistoryHandle *hh; /** @@ -274,15 +279,14 @@ execute_history () bin_len)); } - if (NULL == plugin_handle->get_history - (plugin_handle->cls, - account_section, - TALER_BANK_DIRECTION_BOTH, - since_when_bin, - bin_len, - -10, - history_cb, - NULL)) + if (NULL == (hh = plugin_handle->get_history (plugin_handle->cls, + account_section, + TALER_BANK_DIRECTION_BOTH, + since_when_bin, + bin_len, + -10, + &history_cb, + NULL))) { fprintf (stderr, "Could not request the transaction history.\n"); @@ -297,9 +301,21 @@ execute_history () * * @param cls closure. */ -void +static void do_shutdown (void *cls) { + if (NULL != hh) + { + plugin_handle->get_history_cancel (plugin_handle->cls, + hh); + hh = NULL; + } + if (NULL != ph) + { + plugin_handle->prepare_wire_transfer_cancel (plugin_handle->cls, + ph); + ph = NULL; + } TALER_WIRE_plugin_unload (plugin_handle); } @@ -377,8 +393,7 @@ main (int argc, struct GNUNET_GETOPT_CommandLineOption options[] = { GNUNET_GETOPT_option_flag ('H', "history", - "Ask to get a list of 10" - " transactions.", + "Ask to get a list of 10 transactions.", &history), GNUNET_GETOPT_option_flag ('t', "transfer", @@ -398,9 +413,7 @@ main (int argc, GNUNET_GETOPT_option_string ('s', "section", "ACCOUNT-SECTION", - "Which config section has the" - " credentials to access the" - " bank. Mandatory.\n", + "Which config section has the credentials to access the bank. Mandatory.\n", &account_section), GNUNET_GETOPT_option_string ('a', "amount", @@ -410,8 +423,7 @@ main (int argc, GNUNET_GETOPT_option_string ('d', "destination", "PAYTO-URL", - "Destination account for the" - " wire transfer.", + "Destination account for the wire transfer.", &destination_account_url), GNUNET_GETOPT_OPTION_END }; diff --git a/src/include/taler_wire_plugin.h b/src/include/taler_wire_plugin.h index eb43f2277..ffc7adf59 100644 --- a/src/include/taler_wire_plugin.h +++ b/src/include/taler_wire_plugin.h @@ -96,7 +96,8 @@ struct TALER_WIRE_TransferDetails * * @param cls closure * @param ec taler error code - * @param dir direction of the transfer + * @param dir direction of the transfer, #TALER_BANK_DIRECTION_NONE when + * the iteration is complete * @param row_off identification of the position at which we are querying * @param row_off_size number of bytes in @a row_off * @param details details about the wire transfer @@ -368,53 +369,6 @@ struct TALER_WIRE_Plugin (*reject_transfer_cancel)(void *cls, struct TALER_WIRE_RejectHandle *rh); - - /** - * Ask the plugin which data is needed to register the merchant - * into the banking institution. - * - * @param enc[out] where to store the JSON formatted list of - * needed values. The merchant will use this list to - * show a HTML form to the business in order to collect that data. - * This value will have to be freed by the caller. - * @param private_person GNUNET_OK if the merchant to be registered - * has a legal status of "person", for example they are freelance - * journalists. - * @param business GNUNET_OK if the merchant has the legal status - * of "business", so to say a "ordinary" shop. Cannot be - * both private and business though. - * @return GNUNET_OK upon successful `enc' allocation and definition, - * GNUNET_NO if _no_ data is needed at all, GNUNET_SYSERR - * for all the other cases. - */ - int - (*merchant_data)(char **out, - unsigned int private_person, - unsigned int business); - - /** - * Send data to the banking institution in order to get the - * merchant registered. - * - * @param cls closure - * @param body subset of information to be sent to the bank. - * The plugin implementation is free to modify this value. - * @param mrcb Callback to process the outcome. - */ - struct TALER_WIRE_MerchantRegisterHandle * - (*merchant_register)(void *cls, - const char *body, - TALER_WIRE_MerchantRegisterCallback mrcb); - - /** - * Cancel pending operation of merchant registering. - * - * @param cls closure - * @param mrh handle to the pending operation to be cancelled. - */ - void - (*merchant_register_cancel)(void *cls, - struct TALER_WIRE_MerchantRegisterHandle *mrh); }; diff --git a/src/wire-plugins/plugin_wire_taler-bank.c b/src/wire-plugins/plugin_wire_taler-bank.c index 97b1e6c84..e1db643d3 100644 --- a/src/wire-plugins/plugin_wire_taler-bank.c +++ b/src/wire-plugins/plugin_wire_taler-bank.c @@ -765,7 +765,8 @@ struct TALER_WIRE_HistoryHandle { /** - * Function to call with results. + * Function to call with results, can become NULL if the + * application cancels the iteration. */ TALER_WIRE_HistoryResultCallback hres_cb; @@ -797,6 +798,7 @@ static void taler_bank_get_history_cancel (void *cls, struct TALER_WIRE_HistoryHandle *whh) { + (void) cls; if (NULL != whh->hh) { TALER_BANK_history_cancel (whh->hh); @@ -893,7 +895,11 @@ bhist_cb (void *cls, GNUNET_break (NULL != whh->hh); /* Once we get the sentinel element, the handle becomes invalid. */ if (TALER_BANK_DIRECTION_NONE == dir) + { whh->hh = NULL; + taler_bank_get_history_cancel (NULL, + whh); + } return; } case MHD_HTTP_NO_CONTENT: @@ -904,6 +910,9 @@ bhist_cb (void *cls, NULL, 0, NULL); + whh->hh = NULL; + taler_bank_get_history_cancel (NULL, + whh); break; default: GNUNET_log (GNUNET_ERROR_TYPE_ERROR, @@ -917,6 +926,9 @@ bhist_cb (void *cls, NULL, 0, NULL); + whh->hh = NULL; + taler_bank_get_history_cancel (NULL, + whh); break; } whh->hh = NULL; @@ -962,6 +974,7 @@ taler_bank_get_history (void *cls, uint64_t start_row; struct TALER_Account account; + GNUNET_assert (NULL != hres_cb); if (0 == num_results) { GNUNET_break (0); @@ -1019,13 +1032,12 @@ taler_bank_get_history (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not parse the auth values from '%s'\n", account_section); + TALER_WIRE_account_free (&account); GNUNET_free (whh); return NULL; } - whh->hres_cb = hres_cb; whh->hres_cb_cls = hres_cb_cls; - whh->hh = TALER_BANK_history (tc->ctx, account.details.x_taler_bank.bank_base_url, &whh->auth, @@ -1040,16 +1052,16 @@ taler_bank_get_history (void *cls, if (NULL == whh->hh) { GNUNET_break (0); - taler_bank_get_history_cancel (NULL, + taler_bank_get_history_cancel (tc, whh); TALER_WIRE_account_free (&account); return NULL; } TALER_WIRE_account_free (&account); - GNUNET_assert (NULL != whh); return whh; } + /** * Context for a rejection operation. */ diff --git a/src/wire-plugins/test_wire_plugin_transactions_taler-bank.c b/src/wire-plugins/test_wire_plugin_transactions_taler-bank.c index 2cda49a05..fa0db5b41 100644 --- a/src/wire-plugins/test_wire_plugin_transactions_taler-bank.c +++ b/src/wire-plugins/test_wire_plugin_transactions_taler-bank.c @@ -107,6 +107,7 @@ static struct TALER_WireTransferIdentifierRawP wtid; static void do_shutdown (void *cls) { + (void) cls; TALER_FAKEBANK_stop (fb); fb = NULL; if (NULL != eh) @@ -186,11 +187,11 @@ history_result_cb uint64_t serialh; struct TALER_Amount amount; - hh = NULL; if ( (TALER_BANK_DIRECTION_NONE == dir) && (GNUNET_OK == global_ret) ) { GNUNET_SCHEDULER_shutdown (); + hh = NULL; return GNUNET_OK; } if (sizeof (uint64_t) != row_off_size) @@ -251,6 +252,7 @@ confirmation_cb (void *cls, const char *emsg) { uint64_t tmp; + eh = NULL; if (GNUNET_OK != success) { @@ -259,13 +261,10 @@ confirmation_cb (void *cls, GNUNET_SCHEDULER_shutdown (); return; } - memcpy (&tmp, row_id, row_id_size); - serial_target = GNUNET_ntohll (tmp); - hh = plugin->get_history (plugin->cls, my_account, TALER_BANK_DIRECTION_BOTH, |