Revamp return results of plugins

This commit is contained in:
pscott
2021-04-24 12:14:36 +02:00
parent dcacda44c1
commit 6cd4b6e2aa
3 changed files with 14 additions and 9 deletions

View File

@@ -123,7 +123,7 @@ int eth_plugin_call(uint8_t *contractAddress, int method, void *parameter) {
pluginRO.txContent = &tmpContent.txContent;
if (contractAddress == NULL) {
if (dataContext.tokenContext.pluginStatus == ETH_PLUGIN_RESULT_UNAVAILABLE) {
if (dataContext.tokenContext.pluginStatus < ETH_PLUGIN_RESULT_UNSUCCESSFUL) {
PRINTF("Cached plugin call but no plugin available\n");
return 0;
}

View File

@@ -21,12 +21,16 @@ typedef enum {
} eth_plugin_msg_t;
typedef enum {
// Unsuccesful return values
ETH_PLUGIN_RESULT_ERROR = 0x00,
ETH_PLUGIN_RESULT_OK = 0x01,
ETH_PLUGIN_RESULT_OK_ALIAS = 0x02,
ETH_PLUGIN_RESULT_FALLBACK = 0x03,
ETH_PLUGIN_RESULT_UNAVAILABLE = 0x04
ETH_PLUGIN_RESULT_UNAVAILABLE = 0x01,
ETH_PLUGIN_RESULT_UNSUCCESSFUL = 0x02, // Used for comparison
// Successful return values
ETH_PLUGIN_RESULT_SUCCESSFUL = 0x03, // Used for comparison
ETH_PLUGIN_RESULT_OK = 0x04,
ETH_PLUGIN_RESULT_OK_ALIAS = 0x05,
ETH_PLUGIN_RESULT_FALLBACK = 0x06
} eth_plugin_result_t;

View File

@@ -57,6 +57,7 @@ customStatus_e customProcessor(txContext_t *context) {
case ETH_PLUGIN_RESULT_ERROR:
return CUSTOM_FAULT;
case ETH_PLUGIN_RESULT_UNAVAILABLE:
case ETH_PLUGIN_RESULT_UNSUCCESSFUL:
break;
default:
dataContext.tokenContext.fieldIndex = 0;
@@ -83,7 +84,7 @@ customStatus_e customProcessor(txContext_t *context) {
blockSize = 4;
} else {
if (!N_storage.contractDetails &&
dataContext.tokenContext.pluginStatus != ETH_PLUGIN_RESULT_OK) {
dataContext.tokenContext.pluginStatus <= ETH_PLUGIN_RESULT_UNSUCCESSFUL) {
return CUSTOM_NOT_HANDLED;
}
blockSize = 32 - (dataContext.tokenContext.fieldOffset % 32);
@@ -112,7 +113,7 @@ customStatus_e customProcessor(txContext_t *context) {
if (copySize == blockSize) {
// Can process or display
if (dataContext.tokenContext.pluginStatus == ETH_PLUGIN_RESULT_OK) {
if (dataContext.tokenContext.pluginStatus >= ETH_PLUGIN_RESULT_SUCCESSFUL) {
ethPluginProvideParameter_t pluginProvideParameter;
eth_plugin_prepare_provide_parameter(&pluginProvideParameter,
dataContext.tokenContext.data,
@@ -263,7 +264,7 @@ void finalizeParsing(bool direct) {
32);
// Finalize the plugin handling
if (dataContext.tokenContext.pluginStatus == ETH_PLUGIN_RESULT_OK) {
if (dataContext.tokenContext.pluginStatus >= ETH_PLUGIN_RESULT_SUCCESSFUL) {
genericUI = false;
eth_plugin_prepare_finalize(&pluginFinalize);
if (!eth_plugin_call(NULL, ETH_PLUGIN_FINALIZE, (void *) &pluginFinalize)) {