diff options
Diffstat (limited to 'src/exchange/taler-exchange-httpd_extensions.c')
-rw-r--r-- | src/exchange/taler-exchange-httpd_extensions.c | 66 |
1 files changed, 39 insertions, 27 deletions
diff --git a/src/exchange/taler-exchange-httpd_extensions.c b/src/exchange/taler-exchange-httpd_extensions.c index 2aee1b5c..e8d3e4af 100644 --- a/src/exchange/taler-exchange-httpd_extensions.c +++ b/src/exchange/taler-exchange-httpd_extensions.c @@ -77,67 +77,66 @@ extension_update_event_cb (void *cls, return; } - // Get the config from the database as string - if (extension->has_config) + // Get the manifest from the database as string { - char *config_str = NULL; + char *manifest_str = NULL; enum GNUNET_DB_QueryStatus qs; json_error_t err; - json_t *config; + json_t *manifest_js; enum GNUNET_GenericReturnValue ret; - qs = TEH_plugin->get_extension_config (TEH_plugin->cls, - extension->name, - &config_str); + qs = TEH_plugin->get_extension_manifest (TEH_plugin->cls, + extension->name, + &manifest_str); if (qs < 0) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Couldn't get extension config\n"); + "Couldn't get extension manifest\n"); GNUNET_break (0); return; } // No config found -> disable extension - if (NULL == config_str) + if (NULL == manifest_str) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "No configuration found for extension %s, disabling it\n", + "No manifest found for extension %s, disabling it\n", extension->name); extension->disable ((struct TALER_Extension *) extension); return; } // Parse the string as JSON - config = json_loads (config_str, JSON_DECODE_ANY, &err); - if (NULL == config) + manifest_js = json_loads (manifest_str, JSON_DECODE_ANY, &err); + if (NULL == manifest_js) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Failed to parse config for extension `%s' as JSON: %s (%s)\n", + "Failed to parse manifest for extension `%s' as JSON: %s (%s)\n", extension->name, err.text, err.source); GNUNET_break (0); - free (config_str); + free (manifest_js); return; } // Call the parser for the extension - ret = extension->load_json_config ( + ret = extension->load_config ( (struct TALER_Extension *) extension, - json_object_get (config, "config")); + json_object_get (manifest_js, "config")); if (GNUNET_OK != ret) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Couldn't parse configuration for extension %s from the database: %s\n", + "Couldn't parse configuration for extension %s from the manifest in the database: %s\n", extension->name, - config_str); + manifest_str); GNUNET_break (0); } - free (config_str); - json_decref (config); + free (manifest_str); + json_decref (manifest_js); } /* Special case age restriction: Update global flag and mask */ @@ -145,11 +144,15 @@ extension_update_event_cb (void *cls, { const struct TALER_AgeRestrictionConfig *conf = TALER_extensions_get_age_restriction_config (); + TEH_age_restriction_enabled = false; if (NULL != conf) + { + TEH_age_restriction_enabled = true; TEH_age_restriction_config = *conf; + } GNUNET_log (GNUNET_ERROR_TYPE_INFO, "[age restriction] DB event has changed the config to %s with mask: %s\n", - conf->enabled ? "enabled": "disabled", + TEH_age_restriction_enabled ? "enabled": "DISABLED", TALER_age_mask_to_string (&conf->mask)); } @@ -167,13 +170,22 @@ TEH_extensions_init () /* Load the shared libraries first */ if (GNUNET_OK != - TALER_extensions_load (TEH_cfg)) + TALER_extensions_init (TEH_cfg)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "failed to load extensions"); return GNUNET_SYSERR; } + /* Check for age restriction */ + { + const struct TALER_AgeRestrictionConfig *arc; + + if (NULL != + (arc = TALER_extensions_get_age_restriction_config ())) + TEH_age_restriction_config = *arc; + } + extensions_eh = TEH_plugin->event_listen (TEH_plugin->cls, GNUNET_TIME_UNIT_FOREVER_REL, &ev, @@ -192,16 +204,16 @@ TEH_extensions_init () { const struct TALER_Extension *ext = it->extension; uint32_t typ = htonl (ext->type); - char *conf = json_dumps (ext->config_to_json (ext), JSON_COMPACT); + char *manifest = json_dumps (ext->manifest (ext), JSON_COMPACT); - TEH_plugin->set_extension_config (TEH_plugin->cls, - ext->name, - conf); + TEH_plugin->set_extension_manifest (TEH_plugin->cls, + ext->name, + manifest); extension_update_event_cb (NULL, &typ, sizeof(typ)); - free (conf); + free (manifest); } return GNUNET_OK; |