mark out todos

This commit is contained in:
Özgür Kesim 2021-12-30 11:13:42 +01:00
parent 75763f2823
commit c9ab318abc
Signed by: oec
GPG Key ID: 3D76A56D79EDD9D7
4 changed files with 52 additions and 33 deletions

View File

@ -148,37 +148,9 @@ int TEH_check_invariants_flag;
bool TEH_suicide; bool TEH_suicide;
/** /**
* The global manifest with the list supported extensions, sorted by * Global register of extensions
* TALER_Extension_Type.
*
* TODO: This needs to become a dynamic list, once we have a model for
* extensions as plugins.
**/
const struct TALER_Extension TEH_extensions[] = {
[TALER_Extension_AgeRestriction] = {
.type = TALER_Extension_AgeRestriction,
.name = "age_restriction",
.critical = false,
.config = NULL, // disabled per default
/* TODO:
.parse_config = &TALER_Extension_AgeRestriction_parse_config,
.config_to_json = &TALER_Extension_AgeRestriction_config_to_json,
*/ */
}, struct TALER_Extension *TEH_extensions;
[TALER_Extension_Peer2Peer] = {
.type = TALER_Extension_Peer2Peer,
.name = "peer2peer",
.critical = false,
.config = NULL, // disabled per default
},
/* terminator */
[TALER_Extension_Max] = {
.type = TALER_Extension_Max,
.name = NULL,
.critical = false,
.config = NULL,
},
};
/** /**
* Value to return from main() * Value to return from main()

View File

@ -204,7 +204,7 @@ extern struct GNUNET_CURL_Context *TEH_curl_ctx;
/** /**
* The manifest of the available extensions, NULL terminated * The manifest of the available extensions, NULL terminated
*/ */
extern const struct TALER_Extension TEH_extensions[]; extern struct TALER_Extension *TEH_extensions;
/** /**
* @brief Struct describing an URL and the handler for it. * @brief Struct describing an URL and the handler for it.

View File

@ -26,6 +26,47 @@
#include "taler_mhd_lib.h" #include "taler_mhd_lib.h"
#include <jansson.h> #include <jansson.h>
/**
* Create a list with the extensions for Age Restriction and Peer2Peer
*
* TODO oec
*/
static struct TALER_Extension *
register_known_extensions ()
{
/* TODO oec
* - create list of correct size, or linked list?
* - fill data for age restriction and peer2peer
* - set function pointers for parser and json-converter
* - set function pointers for notimplemented?
*/
/**
* The global manifest with the list supported extensions, sorted by
* TALER_Extension_Type.
*
* TODO: This needs to become a dynamic list, once we have a model for
* extensions as plugins.
struct TALER_Extension *TEH_extensions[] = {
[TALER_Extension_AgeRestriction] = {
.type = TALER_Extension_AgeRestriction,
.name = "age_restriction",
.critical = false,
.config = NULL, // disabled per default
// .parse_config = &TALER_Extension_AgeRestriction_parse_config,
// .config_to_json = &TALER_Extension_AgeRestriction_config_to_json,
},
[TALER_Extension_Peer2Peer] = {
.type = TALER_Extension_Peer2Peer,
.name = "peer2peer",
.critical = false,
.config = NULL, // disabled per default
},
};
**/
return NULL;
}
/** /**
* Handler listening for extensions updates by other exchange * Handler listening for extensions updates by other exchange
@ -85,7 +126,7 @@ extension_update_event_cb (void *cls,
} }
/* /*
* TODO: * TODO oec:
* - parse string as json * - parse string as json
* - update global config * - update global config
*/ */
@ -98,6 +139,8 @@ extension_update_event_cb (void *cls,
enum GNUNET_GenericReturnValue enum GNUNET_GenericReturnValue
TEH_extensions_init () TEH_extensions_init ()
{ {
// TEH_extensions = register_known_extensions();
struct GNUNET_DB_EventHeaderP ev = { struct GNUNET_DB_EventHeaderP ev = {
.size = htons (sizeof (ev)), .size = htons (sizeof (ev)),
.type = htons (TALER_DBEVENT_EXCHANGE_EXTENSIONS_UPDATED), .type = htons (TALER_DBEVENT_EXCHANGE_EXTENSIONS_UPDATED),

View File

@ -179,6 +179,7 @@ TEH_handler_management_post_extensions (
}; };
MHD_RESULT ret; MHD_RESULT ret;
// Parse the top level json structure
{ {
enum GNUNET_GenericReturnValue res; enum GNUNET_GenericReturnValue res;
@ -191,6 +192,7 @@ TEH_handler_management_post_extensions (
return MHD_YES; /* failure */ return MHD_YES; /* failure */
} }
// Ensure we have two arrays of the same size
if (! (json_is_array (extensions) && if (! (json_is_array (extensions) &&
json_is_array (extensions_sigs)) ) json_is_array (extensions_sigs)) )
{ {
@ -223,6 +225,7 @@ TEH_handler_management_post_extensions (
sec.extensions_sigs = GNUNET_new_array (sec.num_extensions, sec.extensions_sigs = GNUNET_new_array (sec.num_extensions,
struct TALER_MasterSignatureP); struct TALER_MasterSignatureP);
// Now parse individual extensions and signatures from those arrays.
for (unsigned int i = 0; i<sec.num_extensions; i++) for (unsigned int i = 0; i<sec.num_extensions; i++)
{ {
// 1. parse the extension out of the json // 1. parse the extension out of the json
@ -327,6 +330,7 @@ TEH_handler_management_post_extensions (
*/ */
json_incref (sec.extensions[i].config); json_incref (sec.extensions[i].config);
GNUNET_JSON_parse_free (ext_spec); GNUNET_JSON_parse_free (ext_spec);
} /* for-loop */ } /* for-loop */
GNUNET_log (GNUNET_ERROR_TYPE_INFO, GNUNET_log (GNUNET_ERROR_TYPE_INFO,