NFC: Move api_resolver out of NfcSupportedCards

This commit is contained in:
Willy-JL
2025-04-13 02:56:44 +01:00
parent 21c9852666
commit 7b95117e32
4 changed files with 13 additions and 10 deletions

View File

@@ -1,11 +1,9 @@
#include "nfc_supported_cards.h"
#include "../api/nfc_app_api_interface.h"
#include "../plugins/supported_cards/nfc_supported_card_plugin.h"
#include <flipper_application/flipper_application.h>
#include <flipper_application/plugins/plugin_manager.h>
#include <flipper_application/plugins/composite_resolver.h>
#include <loader/firmware_api/firmware_api.h>
#include <furi.h>
@@ -52,12 +50,9 @@ struct NfcSupportedCards {
NfcSupportedCardsLoadContext* load_context;
};
NfcSupportedCards* nfc_supported_cards_alloc(void) {
NfcSupportedCards* nfc_supported_cards_alloc(CompositeApiResolver* api_resolver) {
NfcSupportedCards* instance = malloc(sizeof(NfcSupportedCards));
instance->api_resolver = composite_api_resolver_alloc();
composite_api_resolver_add(instance->api_resolver, firmware_api_interface);
composite_api_resolver_add(instance->api_resolver, nfc_application_api_interface);
instance->api_resolver = api_resolver;
NfcSupportedCardsPluginCache_init(instance->plugins_cache_arr);
@@ -76,7 +71,6 @@ void nfc_supported_cards_free(NfcSupportedCards* instance) {
}
NfcSupportedCardsPluginCache_clear(instance->plugins_cache_arr);
composite_api_resolver_free(instance->api_resolver);
free(instance);
}

View File

@@ -7,6 +7,7 @@
#pragma once
#include <core/string.h>
#include <flipper_application/plugins/composite_resolver.h>
#include <nfc/nfc.h>
#include <nfc/nfc_device.h>
@@ -25,7 +26,7 @@ typedef struct NfcSupportedCards NfcSupportedCards;
*
* @return pointer to allocated NfcSupportedCards instance.
*/
NfcSupportedCards* nfc_supported_cards_alloc(void);
NfcSupportedCards* nfc_supported_cards_alloc(CompositeApiResolver* api_resolver);
/**
* @brief Delete an NfcSupportedCards instance

View File

@@ -1,7 +1,9 @@
#include "nfc_app_i.h"
#include "api/nfc_app_api_interface.h"
#include "helpers/protocol_support/nfc_protocol_support.h"
#include <dolphin/dolphin.h>
#include <loader/firmware_api/firmware_api.h>
#include <applications/main/archive/helpers/archive_helpers_ext.h>
bool nfc_custom_event_callback(void* context, uint32_t event) {
@@ -50,12 +52,16 @@ NfcApp* nfc_app_alloc(void) {
instance->nfc = nfc_alloc();
instance->api_resolver = composite_api_resolver_alloc();
composite_api_resolver_add(instance->api_resolver, firmware_api_interface);
composite_api_resolver_add(instance->api_resolver, nfc_application_api_interface);
instance->detected_protocols = nfc_detected_protocols_alloc();
instance->felica_auth = felica_auth_alloc();
instance->mf_ul_auth = mf_ultralight_auth_alloc();
instance->slix_unlock = slix_unlock_alloc();
instance->mfc_key_cache = mf_classic_key_cache_alloc();
instance->nfc_supported_cards = nfc_supported_cards_alloc();
instance->nfc_supported_cards = nfc_supported_cards_alloc(instance->api_resolver);
// Nfc device
instance->nfc_device = nfc_device_alloc();

View File

@@ -36,6 +36,7 @@
#include "helpers/felica_auth.h"
#include "helpers/slix_unlock.h"
#include <flipper_application/plugins/composite_resolver.h>
#include <loader/loader.h>
#include <dialogs/dialogs.h>
#include <storage/storage.h>
@@ -149,6 +150,7 @@ struct NfcApp {
Mfkey32Logger* mfkey32_logger;
MfUserDict* mf_user_dict;
MfClassicKeyCache* mfc_key_cache;
CompositeApiResolver* api_resolver;
NfcSupportedCards* nfc_supported_cards;
NfcDevice* nfc_device;