diff options
Diffstat (limited to 'src/authorization/anastasis_authorization_plugin_iban.c')
-rw-r--r-- | src/authorization/anastasis_authorization_plugin_iban.c | 37 |
1 files changed, 14 insertions, 23 deletions
diff --git a/src/authorization/anastasis_authorization_plugin_iban.c b/src/authorization/anastasis_authorization_plugin_iban.c index d1a71f9..548b5c0 100644 --- a/src/authorization/anastasis_authorization_plugin_iban.c +++ b/src/authorization/anastasis_authorization_plugin_iban.c | |||
@@ -57,9 +57,9 @@ struct IBAN_Context | |||
57 | char *business_name; | 57 | char *business_name; |
58 | 58 | ||
59 | /** | 59 | /** |
60 | * Database handle. | 60 | * Handle to interact with a authorization backend. |
61 | */ | 61 | */ |
62 | struct ANASTASIS_DatabasePlugin *db; | 62 | const struct ANASTASIS_AuthorizationContext *ac; |
63 | 63 | ||
64 | /** | 64 | /** |
65 | * Amount we expect to be transferred. | 65 | * Amount we expect to be transferred. |
@@ -407,14 +407,14 @@ iban_process (struct ANASTASIS_AUTHORIZATION_State *as, | |||
407 | GNUNET_CRYPTO_hash (as->iban_number, | 407 | GNUNET_CRYPTO_hash (as->iban_number, |
408 | strlen (as->iban_number), | 408 | strlen (as->iban_number), |
409 | &espec.debit_iban_hash); | 409 | &espec.debit_iban_hash); |
410 | as->eh = ctx->db->event_listen (ctx->db->cls, | 410 | as->eh = ctx->ac->db->event_listen (ctx->ac->db->cls, |
411 | &espec.header, | 411 | &espec.header, |
412 | &bank_event_cb, | 412 | &bank_event_cb, |
413 | as); | 413 | as); |
414 | } | 414 | } |
415 | qs = ctx->db->test_challenge_code_satisfied (ctx->db->cls, | 415 | qs = ctx->ac->db->test_challenge_code_satisfied (ctx->ac->db->cls, |
416 | &as->truth_uuid, | 416 | &as->truth_uuid, |
417 | as->code); | 417 | as->code); |
418 | switch (qs) | 418 | switch (qs) |
419 | { | 419 | { |
420 | case GNUNET_DB_STATUS_HARD_ERROR: | 420 | case GNUNET_DB_STATUS_HARD_ERROR: |
@@ -458,7 +458,7 @@ iban_cleanup (struct ANASTASIS_AUTHORIZATION_State *as) | |||
458 | 458 | ||
459 | if (NULL != as->eh) | 459 | if (NULL != as->eh) |
460 | { | 460 | { |
461 | ctx->db->event_listen_cancel (as->eh); | 461 | ctx->ac->db->event_listen_cancel (as->eh); |
462 | as->eh = NULL; | 462 | as->eh = NULL; |
463 | } | 463 | } |
464 | GNUNET_free (as->iban_number); | 464 | GNUNET_free (as->iban_number); |
@@ -469,14 +469,15 @@ iban_cleanup (struct ANASTASIS_AUTHORIZATION_State *as) | |||
469 | /** | 469 | /** |
470 | * Initialize email based authorization plugin | 470 | * Initialize email based authorization plugin |
471 | * | 471 | * |
472 | * @param cls a configuration instance | 472 | * @param cls a `struct ANASTASIS_AuthorizationContext` |
473 | * @return NULL on error, otherwise a `struct ANASTASIS_AuthorizationPlugin` | 473 | * @return NULL on error, otherwise a `struct ANASTASIS_AuthorizationPlugin` |
474 | */ | 474 | */ |
475 | void * | 475 | void * |
476 | libanastasis_plugin_authorization_iban_init (void *cls) | 476 | libanastasis_plugin_authorization_iban_init (void *cls) |
477 | { | 477 | { |
478 | struct ANASTASIS_AuthorizationContext *ac = cls; | ||
478 | struct ANASTASIS_AuthorizationPlugin *plugin; | 479 | struct ANASTASIS_AuthorizationPlugin *plugin; |
479 | struct GNUNET_CONFIGURATION_Handle *cfg = cls; | 480 | const struct GNUNET_CONFIGURATION_Handle *cfg = ac->cfg; |
480 | struct IBAN_Context *ctx; | 481 | struct IBAN_Context *ctx; |
481 | 482 | ||
482 | ctx = GNUNET_new (struct IBAN_Context); | 483 | ctx = GNUNET_new (struct IBAN_Context); |
@@ -531,21 +532,12 @@ libanastasis_plugin_authorization_iban_init (void *cls) | |||
531 | } | 532 | } |
532 | GNUNET_free (fn); | 533 | GNUNET_free (fn); |
533 | } | 534 | } |
534 | ctx->db = ANASTASIS_DB_plugin_load (cfg); | 535 | ctx->ac = ac; |
535 | if (NULL == ctx->db) | ||
536 | { | ||
537 | json_decref (ctx->messages); | ||
538 | GNUNET_free (ctx->business_iban); | ||
539 | GNUNET_free (ctx->business_name); | ||
540 | GNUNET_free (ctx); | ||
541 | return NULL; | ||
542 | } | ||
543 | if (GNUNET_OK != | 536 | if (GNUNET_OK != |
544 | TALER_BANK_auth_parse_cfg (cfg, | 537 | TALER_BANK_auth_parse_cfg (cfg, |
545 | "authorization-iban", | 538 | "authorization-iban", |
546 | &ctx->auth)) | 539 | &ctx->auth)) |
547 | { | 540 | { |
548 | ANASTASIS_DB_plugin_unload (ctx->db); | ||
549 | json_decref (ctx->messages); | 541 | json_decref (ctx->messages); |
550 | GNUNET_free (ctx->business_iban); | 542 | GNUNET_free (ctx->business_iban); |
551 | GNUNET_free (ctx->business_name); | 543 | GNUNET_free (ctx->business_name); |
@@ -579,7 +571,6 @@ libanastasis_plugin_authorization_iban_done (void *cls) | |||
579 | struct ANASTASIS_AuthorizationPlugin *plugin = cls; | 571 | struct ANASTASIS_AuthorizationPlugin *plugin = cls; |
580 | struct IBAN_Context *ctx = plugin->cls; | 572 | struct IBAN_Context *ctx = plugin->cls; |
581 | 573 | ||
582 | ANASTASIS_DB_plugin_unload (ctx->db); | ||
583 | TALER_BANK_auth_free (&ctx->auth); | 574 | TALER_BANK_auth_free (&ctx->auth); |
584 | json_decref (ctx->messages); | 575 | json_decref (ctx->messages); |
585 | GNUNET_free (ctx->business_iban); | 576 | GNUNET_free (ctx->business_iban); |