aboutsummaryrefslogtreecommitdiff
path: root/src/extensions/age_restriction
diff options
context:
space:
mode:
Diffstat (limited to 'src/extensions/age_restriction')
-rw-r--r--src/extensions/age_restriction/Makefile.am2
-rw-r--r--src/extensions/age_restriction/age_restriction.c (renamed from src/extensions/age_restriction/extension_age_restriction.c)78
2 files changed, 17 insertions, 63 deletions
diff --git a/src/extensions/age_restriction/Makefile.am b/src/extensions/age_restriction/Makefile.am
index e90c1962..85d67653 100644
--- a/src/extensions/age_restriction/Makefile.am
+++ b/src/extensions/age_restriction/Makefile.am
@@ -22,7 +22,7 @@ libtaler_extension_age_restriction_la_LDFLAGS = \
-no-undefined
libtaler_extension_age_restriction_la_SOURCES = \
- extension_age_restriction.c
+ age_restriction.c
libtaler_extension_age_restriction_la_LIBADD = \
$(top_builddir)/src/json/libtalerjson.la \
diff --git a/src/extensions/age_restriction/extension_age_restriction.c b/src/extensions/age_restriction/age_restriction.c
index 697d066f..a1a11e4f 100644
--- a/src/extensions/age_restriction/extension_age_restriction.c
+++ b/src/extensions/age_restriction/age_restriction.c
@@ -14,7 +14,7 @@
TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
/**
- * @file extension_age_restriction.c
+ * @file age_restriction.c
* @brief Utility functions regarding age restriction
* @author Özgür Kesim
*/
@@ -51,26 +51,19 @@ age_restriction_disable (
ext->enabled = false;
ext->config = NULL;
- if (NULL != ext->config_json)
- {
- json_decref (ext->config_json);
- ext->config_json = NULL;
- }
-
- AR_config.enabled = false;
AR_config.mask.bits = 0;
AR_config.num_groups = 0;
}
/**
- * @brief implements the TALER_Extension.load_json_config interface.
+ * @brief implements the TALER_Extension.load_config interface.
*
* @param ext if NULL, only tests the configuration
* @param jconfig the configuration as json
*/
static enum GNUNET_GenericReturnValue
-age_restriction_load_json_config (
+age_restriction_load_config (
struct TALER_Extension *ext,
json_t *jconfig)
{
@@ -98,14 +91,8 @@ age_restriction_load_json_config (
AR_config.num_groups = __builtin_popcount (mask.bits) - 1;
}
- AR_config.enabled = true;
ext->config = &AR_config;
-
- if (NULL != ext->config_json)
- json_decref (ext->config_json);
-
ext->enabled = true;
- ext->config_json = json_copy (jconfig);
json_decref (jconfig);
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
@@ -117,13 +104,13 @@ age_restriction_load_json_config (
/**
- * @brief implements the TALER_Extension.config_to_json interface.
+ * @brief implements the TALER_Extension.manifest interface.
*
* @param ext if NULL, only tests the configuration
* @return configuration as json_t* object, maybe NULL
*/
static json_t *
-age_restriction_config_to_json (
+age_restriction_manifest (
const struct TALER_Extension *ext)
{
char *mask_str;
@@ -131,13 +118,6 @@ age_restriction_config_to_json (
GNUNET_assert (NULL != ext);
- if (! ext->enabled)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "age restriction not enabled");
- return json_null ();
- }
-
if (NULL == ext->config)
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
@@ -145,11 +125,6 @@ age_restriction_config_to_json (
return json_null ();
}
- if (NULL != ext->config_json)
- {
- return json_copy (ext->config_json);
- }
-
mask_str = TALER_age_mask_to_string (&AR_config.mask);
conf = GNUNET_JSON_PACK (
GNUNET_JSON_pack_string ("age_groups", mask_str)
@@ -165,36 +140,19 @@ age_restriction_config_to_json (
}
-/**
- * @brief implements the TALER_Extension.test_json_config interface.
- *
- * @param config configuration as json_t* to test
- * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise.
- */
-static enum GNUNET_GenericReturnValue
-age_restriction_test_json_config (
- const json_t *config)
-{
- struct TALER_AgeMask mask = {0};
-
- return TALER_JSON_parse_age_groups (config, &mask);
-}
-
-
/* The extension for age restriction */
-struct TALER_Extension TE_extension_age_restriction = {
+struct TALER_Extension TE_age_restriction = {
.type = TALER_Extension_AgeRestriction,
.name = "age_restriction",
.critical = false,
.version = "1",
.enabled = false, /* disabled per default */
- .has_config = true, /* we need to store configuration */
.config = NULL,
- .config_json = NULL,
.disable = &age_restriction_disable,
- .test_json_config = &age_restriction_test_json_config,
- .load_json_config = &age_restriction_load_json_config,
- .config_to_json = &age_restriction_config_to_json,
+ .load_config = &age_restriction_load_config,
+ .manifest = &age_restriction_manifest,
+ .deposit_handler = NULL,
+ .http_get_handler = NULL,
.http_post_handler = NULL,
};
@@ -261,23 +219,20 @@ libtaler_extension_age_restriction_init (void *arg)
AR_config.mask = mask;
AR_config.num_groups = __builtin_popcount (mask.bits) - 1; /* no underflow, first bit always set */
- AR_config.enabled = true;
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"[age restriction] setting age mask to %s with #groups: %d\n",
TALER_age_mask_to_string (&AR_config.mask),
__builtin_popcount (AR_config.mask.bits) - 1);
- TE_extension_age_restriction.config = &AR_config;
- TE_extension_age_restriction.enabled = true;
+ TE_age_restriction.config = &AR_config;
- /* Note: we do now have TE_age_restriction_config set, however
- * ext->config_json is NOT set, i.e. the extension is not yet active! For
- * age restriction to become active, load_json_config must have been
- * called. */
+ /* Note: we do now have TE_age_restriction_config set, however the extension
+ * is not yet enabled! For age restriction to become active, load_config must
+ * have been called. */
GNUNET_free (groups);
- return &TE_extension_age_restriction;
+ return &TE_age_restriction;
}
@@ -292,11 +247,10 @@ libtaler_extension_age_restriction_done (void *arg)
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"[age restriction] disabling and unloading");
- AR_config.enabled = 0;
AR_config.mask.bits = 0;
AR_config.num_groups = 0;
return NULL;
}
-/* end of extension_age_restriction.c */
+/* end of age_restriction.c */