summaryrefslogtreecommitdiff
path: root/src/authorization
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2021-08-18 17:37:58 +0200
committerChristian Grothoff <christian@grothoff.org>2021-08-18 17:37:58 +0200
commit5f288737d51441694b2c25a6e6591cf2735b0730 (patch)
treeee55f9bd533158bda4ea369c0ce81222bfba57f7 /src/authorization
parentd67df6dfa492454945414759577ea169ec0f6824 (diff)
downloadanastasis-5f288737d51441694b2c25a6e6591cf2735b0730.tar.gz
anastasis-5f288737d51441694b2c25a6e6591cf2735b0730.tar.bz2
anastasis-5f288737d51441694b2c25a6e6591cf2735b0730.zip
-get anastasis-helper-authorization-iban to build
Diffstat (limited to 'src/authorization')
-rw-r--r--src/authorization/.gitignore1
-rw-r--r--src/authorization/Makefile.am20
-rw-r--r--src/authorization/anastasis-helper-authorization-iban.c60
-rw-r--r--src/authorization/libanastasiseufin/lae_credit.c12
4 files changed, 60 insertions, 33 deletions
diff --git a/src/authorization/.gitignore b/src/authorization/.gitignore
new file mode 100644
index 0000000..0aebea9
--- /dev/null
+++ b/src/authorization/.gitignore
@@ -0,0 +1 @@
+anastasis-helper-authorization-iban
diff --git a/src/authorization/Makefile.am b/src/authorization/Makefile.am
index 5cf6db1..15b16d1 100644
--- a/src/authorization/Makefile.am
+++ b/src/authorization/Makefile.am
@@ -23,6 +23,22 @@ if USE_COVERAGE
XLIB = -lgcov
endif
+bin_PROGRAMS = \
+ anastasis-helper-authorization-iban
+
+anastasis_helper_authorization_iban_SOURCES = \
+ anastasis-helper-authorization-iban.c
+anastasis_helper_authorization_iban_LDADD = \
+ $(top_builddir)/src/stasis/libanastasisdb.la \
+ $(top_builddir)/src/authorization/libanastasiseufin/libanastasiseufin.la \
+ $(top_builddir)/src/util/libanastasisutil.la \
+ -lgnunetcurl \
+ -lgnunetutil \
+ -ljansson \
+ -lmicrohttpd \
+ -lpthread
+
+
lib_LTLIBRARIES = \
libanastasisauthorization.la
@@ -51,6 +67,7 @@ libanastasis_plugin_authorization_file_la_LIBADD = \
$(LTLIBINTL)
libanastasis_plugin_authorization_file_la_LDFLAGS = \
$(ANASTASIS_PLUGIN_LDFLAGS) \
+ $(top_builddir)/src/stasis/libanastasisdb.la \
-ltalerjson \
-ltalermhd \
-ltalerutil \
@@ -66,6 +83,7 @@ libanastasis_plugin_authorization_email_la_LIBADD = \
$(LTLIBINTL)
libanastasis_plugin_authorization_email_la_LDFLAGS = \
$(ANASTASIS_PLUGIN_LDFLAGS) \
+ $(top_builddir)/src/stasis/libanastasisdb.la \
-ltalerjson \
-ltalermhd \
-ltalerutil \
@@ -97,6 +115,7 @@ libanastasis_plugin_authorization_post_la_LIBADD = \
$(LTLIBINTL)
libanastasis_plugin_authorization_post_la_LDFLAGS = \
$(ANASTASIS_PLUGIN_LDFLAGS) \
+ $(top_builddir)/src/stasis/libanastasisdb.la \
-ltalerjson \
-ltalermhd \
-ltalerutil \
@@ -112,6 +131,7 @@ libanastasis_plugin_authorization_sms_la_LIBADD = \
$(LTLIBINTL)
libanastasis_plugin_authorization_sms_la_LDFLAGS = \
$(ANASTASIS_PLUGIN_LDFLAGS) \
+ $(top_builddir)/src/stasis/libanastasisdb.la \
-ltalerjson \
-ltalermhd \
-ltalerutil \
diff --git a/src/authorization/anastasis-helper-authorization-iban.c b/src/authorization/anastasis-helper-authorization-iban.c
index 946b008..066b4cb 100644
--- a/src/authorization/anastasis-helper-authorization-iban.c
+++ b/src/authorization/anastasis-helper-authorization-iban.c
@@ -25,13 +25,14 @@
* - needs to add DB triggers to notify main service of inbound activity
*/
#include "platform.h"
+#include "anastasis_eufin_lib.h"
+#include "anastasis_database_lib.h"
+#include "anastasis_util_lib.h"
+#include <taler/taler_json_lib.h>
#include <gnunet/gnunet_util_lib.h>
#include <jansson.h>
#include <pthread.h>
#include <microhttpd.h>
-#include <taler/taler_json_lib.h>
-#include <XXX_bank_service.h>
-#include "anastasis_db_lib.h"
/**
* How long to wait for an HTTP reply if there
@@ -40,19 +41,24 @@
#define LONGPOLL_TIMEOUT GNUNET_TIME_UNIT_HOURS
/**
+ * How long to wait between HTTP requests?
+ */
+#define RETRY_TIMEOUT GNUNET_TIME_UNIT_MINUTES
+
+/**
* Authentication data needed to access the account.
*/
-static struct BANK_AccountInfo *auth;
+static struct ANASTASIS_EUFIN_AuthenticationData auth;
/**
* Bank account payto://-URI this process is monitoring.
*/
-static struct credit_account_uri;
+static char *credit_account_uri;
/**
* Active request for history.
*/
-static struct BANK_CreditHistoryHandle *hh;
+static struct ANASTASIS_EUFIN_CreditHistoryHandle *hh;
/**
* Handle to the context for interacting with the bank.
@@ -92,6 +98,12 @@ static struct GNUNET_TIME_Relative idle_sleep_interval;
static int global_ret;
/**
+ * Run in test-mode, do not background, only import currently
+ * pending transactions.
+ */
+static int test_mode;
+
+/**
* Current task waiting for execution, if any.
*/
static struct GNUNET_SCHEDULER_Task *task;
@@ -108,7 +120,7 @@ shutdown_task (void *cls)
(void) cls;
if (NULL != hh)
{
- BANK_credit_history_cancel (hh);
+ ANASTASIS_EUFIN_credit_history_cancel (hh);
hh = NULL;
}
if (NULL != ctx)
@@ -157,11 +169,10 @@ history_cb (void *cls,
unsigned int http_status,
enum TALER_ErrorCode ec,
uint64_t serial_id,
- const struct BANK_CreditDetails *details)
+ const struct ANASTASIS_EUFIN_CreditDetails *details)
{
enum GNUNET_DB_QueryStatus qs;
- (void) json;
if (NULL == details)
{
hh = NULL;
@@ -175,9 +186,9 @@ history_cb (void *cls,
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"End of list.\n");
GNUNET_assert (NULL == task);
- task = GNUNET_SCHEDULER_add_at (delayed_until,
- &find_transfers,
- NULL);
+ task = GNUNET_SCHEDULER_add_delayed (idle_sleep_interval,
+ &find_transfers,
+ NULL);
return GNUNET_OK; /* will be ignored anyway */
}
if (serial_id <= latest_row_off)
@@ -200,7 +211,7 @@ history_cb (void *cls,
&details->amount,
details->debit_account_uri,
details->credit_account_uri,
- details->execution_time);
+ details->execution_date);
switch (qs)
{
case GNUNET_DB_STATUS_HARD_ERROR:
@@ -234,20 +245,18 @@ history_cb (void *cls,
static void
find_transfers (void *cls)
{
- enum GNUNET_DB_QueryStatus qs;
-
(void) cls;
task = NULL;
GNUNET_assert (NULL == hh);
- hh = BANK_credit_history (ctx,
- &auth,
- latest_row_off,
- 1024,
- test_mode
- ? GNUNET_TIME_UNIT_ZERO
- : LONGPOLL_TIMEOUT,
- &history_cb,
- NULL);
+ hh = ANASTASIS_EUFIN_credit_history (ctx,
+ &auth,
+ latest_row_off,
+ 1024,
+ test_mode
+ ? GNUNET_TIME_UNIT_ZERO
+ : LONGPOLL_TIMEOUT,
+ &history_cb,
+ NULL);
if (NULL == hh)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -310,8 +319,7 @@ run (void *cls,
GNUNET_break (0);
return;
}
- latest_row_off = FIXME; // need new DB function!
-
+ idle_sleep_interval = RETRY_TIMEOUT;
task = GNUNET_SCHEDULER_add_now (&find_transfers,
NULL);
}
diff --git a/src/authorization/libanastasiseufin/lae_credit.c b/src/authorization/libanastasiseufin/lae_credit.c
index b97536b..e8cabb5 100644
--- a/src/authorization/libanastasiseufin/lae_credit.c
+++ b/src/authorization/libanastasiseufin/lae_credit.c
@@ -117,8 +117,7 @@ parse_account_history (struct ANASTASIS_EUFIN_CreditHistoryHandle *hh,
MHD_HTTP_OK,
TALER_EC_NONE,
row_id,
- &td,
- transaction))
+ &td))
{
hh->hcb = NULL;
GNUNET_JSON_parse_free (hist_spec);
@@ -205,8 +204,7 @@ handle_credit_history_finished (void *cls,
response_code,
ec,
0LLU,
- NULL,
- j);
+ NULL);
ANASTASIS_EUFIN_credit_history_cancel (hh);
}
@@ -272,9 +270,9 @@ ANASTASIS_EUFIN_credit_history (
hh = GNUNET_new (struct ANASTASIS_EUFIN_CreditHistoryHandle);
hh->hcb = hres_cb;
hh->hcb_cls = hres_cb_cls;
- hh->request_url = Anastasis_url_join (auth->wire_gateway_url,
- url,
- NULL);
+ hh->request_url = TALER_url_join (auth->wire_gateway_url,
+ url,
+ NULL);
if (NULL == hh->request_url)
{
GNUNET_free (hh);