2022-09-24 17:47:21 +00:00
|
|
|
#include "subbrute_i.h"
|
|
|
|
#include "subbrute_custom_event.h"
|
2022-09-30 14:36:56 +00:00
|
|
|
#include "scenes/subbrute_scene.h"
|
2022-09-24 17:47:21 +00:00
|
|
|
|
|
|
|
#define TAG "SubBruteApp"
|
|
|
|
|
2022-09-24 18:30:08 +00:00
|
|
|
static bool subbrute_custom_event_callback(void* context, uint32_t event) {
|
2022-09-24 17:47:21 +00:00
|
|
|
furi_assert(context);
|
|
|
|
SubBruteState* instance = context;
|
|
|
|
return scene_manager_handle_custom_event(instance->scene_manager, event);
|
|
|
|
}
|
2022-09-07 13:38:20 +00:00
|
|
|
|
2022-09-24 18:30:08 +00:00
|
|
|
static bool subbrute_back_event_callback(void* context) {
|
2022-09-24 17:47:21 +00:00
|
|
|
furi_assert(context);
|
|
|
|
SubBruteState* instance = context;
|
|
|
|
return scene_manager_handle_back_event(instance->scene_manager);
|
|
|
|
}
|
2022-09-07 13:38:20 +00:00
|
|
|
|
2022-09-24 18:30:08 +00:00
|
|
|
static void subbrute_tick_event_callback(void* context) {
|
2022-09-24 17:47:21 +00:00
|
|
|
furi_assert(context);
|
|
|
|
SubBruteState* instance = context;
|
|
|
|
scene_manager_handle_tick_event(instance->scene_manager);
|
|
|
|
}
|
2022-09-07 13:38:20 +00:00
|
|
|
|
2022-09-24 17:47:21 +00:00
|
|
|
SubBruteState* subbrute_alloc() {
|
|
|
|
SubBruteState* instance = malloc(sizeof(SubBruteState));
|
2022-09-07 13:38:20 +00:00
|
|
|
|
2022-09-30 14:36:56 +00:00
|
|
|
memset(instance->text_store, 0, sizeof(instance->text_store));
|
2022-10-07 22:24:19 +00:00
|
|
|
instance->file_path = furi_string_alloc();
|
2022-09-30 14:36:56 +00:00
|
|
|
|
2022-09-24 17:47:21 +00:00
|
|
|
instance->scene_manager = scene_manager_alloc(&subbrute_scene_handlers, instance);
|
|
|
|
instance->view_dispatcher = view_dispatcher_alloc();
|
2022-09-07 13:38:20 +00:00
|
|
|
|
2022-09-24 18:15:09 +00:00
|
|
|
instance->gui = furi_record_open(RECORD_GUI);
|
|
|
|
|
2022-09-24 17:47:21 +00:00
|
|
|
view_dispatcher_enable_queue(instance->view_dispatcher);
|
|
|
|
view_dispatcher_set_event_callback_context(instance->view_dispatcher, instance);
|
|
|
|
view_dispatcher_set_custom_event_callback(
|
|
|
|
instance->view_dispatcher, subbrute_custom_event_callback);
|
|
|
|
view_dispatcher_set_navigation_event_callback(
|
|
|
|
instance->view_dispatcher, subbrute_back_event_callback);
|
|
|
|
view_dispatcher_set_tick_event_callback(
|
2022-10-08 17:53:31 +00:00
|
|
|
instance->view_dispatcher, subbrute_tick_event_callback, 100);
|
2022-09-07 13:38:20 +00:00
|
|
|
|
2022-09-24 18:15:09 +00:00
|
|
|
//Dialog
|
2022-09-24 17:47:21 +00:00
|
|
|
instance->dialogs = furi_record_open(RECORD_DIALOGS);
|
2022-09-24 18:15:09 +00:00
|
|
|
|
|
|
|
// Notifications
|
2022-09-24 17:47:21 +00:00
|
|
|
instance->notifications = furi_record_open(RECORD_NOTIFICATION);
|
2022-09-07 13:38:20 +00:00
|
|
|
|
2022-09-24 18:15:09 +00:00
|
|
|
// Devices
|
|
|
|
instance->device = subbrute_device_alloc();
|
2022-09-24 17:47:21 +00:00
|
|
|
|
2022-10-09 20:35:44 +00:00
|
|
|
// SubBruteWorker
|
|
|
|
instance->worker = subbrute_worker_alloc();
|
|
|
|
|
2022-09-24 17:47:21 +00:00
|
|
|
// TextInput
|
|
|
|
instance->text_input = text_input_alloc();
|
|
|
|
view_dispatcher_add_view(
|
2022-09-25 13:05:52 +00:00
|
|
|
instance->view_dispatcher,
|
|
|
|
SubBruteViewTextInput,
|
|
|
|
text_input_get_view(instance->text_input));
|
|
|
|
|
2022-09-24 17:47:21 +00:00
|
|
|
// Custom Widget
|
|
|
|
instance->widget = widget_alloc();
|
|
|
|
view_dispatcher_add_view(
|
|
|
|
instance->view_dispatcher, SubBruteViewWidget, widget_get_view(instance->widget));
|
|
|
|
|
|
|
|
// Popup
|
|
|
|
instance->popup = popup_alloc();
|
2022-09-25 13:05:52 +00:00
|
|
|
view_dispatcher_add_view(
|
|
|
|
instance->view_dispatcher, SubBruteViewPopup, popup_get_view(instance->popup));
|
2022-09-24 17:47:21 +00:00
|
|
|
|
|
|
|
// ViewStack
|
|
|
|
instance->view_stack = view_stack_alloc();
|
|
|
|
view_dispatcher_add_view(
|
|
|
|
instance->view_dispatcher, SubBruteViewStack, view_stack_get_view(instance->view_stack));
|
|
|
|
|
|
|
|
// SubBruteMainView
|
|
|
|
instance->view_main = subbrute_main_view_alloc();
|
|
|
|
view_dispatcher_add_view(
|
|
|
|
instance->view_dispatcher,
|
|
|
|
SubBruteViewMain,
|
|
|
|
subbrute_main_view_get_view(instance->view_main));
|
|
|
|
|
|
|
|
// SubBruteAttackView
|
|
|
|
instance->view_attack = subbrute_attack_view_alloc();
|
|
|
|
view_dispatcher_add_view(
|
|
|
|
instance->view_dispatcher,
|
|
|
|
SubBruteViewAttack,
|
|
|
|
subbrute_attack_view_get_view(instance->view_attack));
|
|
|
|
|
|
|
|
//instance->flipper_format = flipper_format_string_alloc();
|
|
|
|
//instance->environment = subghz_environment_alloc();
|
|
|
|
|
|
|
|
return instance;
|
2022-09-07 13:38:20 +00:00
|
|
|
}
|
|
|
|
|
2022-09-24 17:47:21 +00:00
|
|
|
void subbrute_free(SubBruteState* instance) {
|
|
|
|
furi_assert(instance);
|
2022-09-07 13:38:20 +00:00
|
|
|
|
2022-10-09 20:35:44 +00:00
|
|
|
// SubBruteWorker
|
|
|
|
subbrute_worker_stop(instance->worker);
|
|
|
|
subbrute_worker_free(instance->worker);
|
|
|
|
|
2022-09-26 20:07:53 +00:00
|
|
|
// SubBruteDevice
|
|
|
|
subbrute_device_free(instance->device);
|
2022-09-25 21:07:16 +00:00
|
|
|
|
2022-09-24 17:47:21 +00:00
|
|
|
// Notifications
|
|
|
|
notification_message(instance->notifications, &sequence_blink_stop);
|
|
|
|
furi_record_close(RECORD_NOTIFICATION);
|
|
|
|
instance->notifications = NULL;
|
2022-09-07 13:38:20 +00:00
|
|
|
|
2022-09-24 17:47:21 +00:00
|
|
|
// View Main
|
|
|
|
view_dispatcher_remove_view(instance->view_dispatcher, SubBruteViewMain);
|
|
|
|
subbrute_main_view_free(instance->view_main);
|
2022-09-08 02:00:53 +00:00
|
|
|
|
2022-09-24 17:47:21 +00:00
|
|
|
// View Attack
|
|
|
|
view_dispatcher_remove_view(instance->view_dispatcher, SubBruteViewAttack);
|
|
|
|
subbrute_attack_view_free(instance->view_attack);
|
2022-09-07 13:38:20 +00:00
|
|
|
|
2022-09-24 17:47:21 +00:00
|
|
|
// TextInput
|
|
|
|
view_dispatcher_remove_view(instance->view_dispatcher, SubBruteViewTextInput);
|
|
|
|
text_input_free(instance->text_input);
|
2022-09-08 02:00:53 +00:00
|
|
|
|
2022-09-24 17:47:21 +00:00
|
|
|
// Custom Widget
|
|
|
|
view_dispatcher_remove_view(instance->view_dispatcher, SubBruteViewWidget);
|
|
|
|
widget_free(instance->widget);
|
2022-09-07 13:38:20 +00:00
|
|
|
|
2022-09-24 17:47:21 +00:00
|
|
|
// Popup
|
|
|
|
view_dispatcher_remove_view(instance->view_dispatcher, SubBruteViewPopup);
|
|
|
|
popup_free(instance->popup);
|
|
|
|
|
|
|
|
// ViewStack
|
|
|
|
view_dispatcher_remove_view(instance->view_dispatcher, SubBruteViewStack);
|
|
|
|
view_stack_free(instance->view_stack);
|
2022-09-07 13:38:20 +00:00
|
|
|
|
|
|
|
//Dialog
|
|
|
|
furi_record_close(RECORD_DIALOGS);
|
2022-09-24 18:15:09 +00:00
|
|
|
instance->dialogs = NULL;
|
2022-09-07 14:48:24 +00:00
|
|
|
|
2022-09-24 17:47:21 +00:00
|
|
|
// Scene manager
|
|
|
|
scene_manager_free(instance->scene_manager);
|
2022-09-08 02:00:53 +00:00
|
|
|
|
2022-09-24 17:47:21 +00:00
|
|
|
// View Dispatcher
|
|
|
|
view_dispatcher_free(instance->view_dispatcher);
|
2022-09-07 13:38:20 +00:00
|
|
|
|
2022-09-24 17:47:21 +00:00
|
|
|
// GUI
|
|
|
|
furi_record_close(RECORD_GUI);
|
|
|
|
instance->gui = NULL;
|
2022-09-07 14:48:24 +00:00
|
|
|
|
2022-10-07 22:24:19 +00:00
|
|
|
furi_string_free(instance->file_path);
|
2022-09-30 14:36:56 +00:00
|
|
|
|
2022-09-07 13:38:20 +00:00
|
|
|
// The rest
|
2022-09-24 17:47:21 +00:00
|
|
|
free(instance);
|
2022-09-07 13:38:20 +00:00
|
|
|
}
|
|
|
|
|
2022-09-24 17:47:21 +00:00
|
|
|
void subbrute_text_input_callback(void* context) {
|
|
|
|
furi_assert(context);
|
|
|
|
SubBruteState* instance = context;
|
|
|
|
view_dispatcher_send_custom_event(
|
2022-09-25 13:05:52 +00:00
|
|
|
instance->view_dispatcher, SubBruteCustomEventTypeTextEditDone);
|
2022-09-24 17:47:21 +00:00
|
|
|
}
|
2022-09-07 13:38:20 +00:00
|
|
|
|
2022-09-24 17:47:21 +00:00
|
|
|
void subbrute_popup_closed_callback(void* context) {
|
|
|
|
furi_assert(context);
|
|
|
|
SubBruteState* instance = context;
|
|
|
|
view_dispatcher_send_custom_event(
|
|
|
|
instance->view_dispatcher, SubBruteCustomEventTypePopupClosed);
|
|
|
|
}
|
2022-09-07 13:38:20 +00:00
|
|
|
|
2022-09-24 17:47:21 +00:00
|
|
|
// ENTRYPOINT
|
|
|
|
int32_t subbrute_app(void* p) {
|
|
|
|
UNUSED(p);
|
2022-09-25 21:07:16 +00:00
|
|
|
|
2022-09-24 17:47:21 +00:00
|
|
|
SubBruteState* instance = subbrute_alloc();
|
|
|
|
view_dispatcher_attach_to_gui(
|
|
|
|
instance->view_dispatcher, instance->gui, ViewDispatcherTypeFullscreen);
|
|
|
|
scene_manager_next_scene(instance->scene_manager, SubBruteSceneStart);
|
2022-09-25 21:07:16 +00:00
|
|
|
|
2022-09-24 17:47:21 +00:00
|
|
|
furi_hal_power_suppress_charge_enter();
|
2022-09-26 14:27:58 +00:00
|
|
|
notification_message(instance->notifications, &sequence_display_backlight_on);
|
2022-09-24 17:47:21 +00:00
|
|
|
view_dispatcher_run(instance->view_dispatcher);
|
2022-09-07 14:48:24 +00:00
|
|
|
furi_hal_power_suppress_charge_exit();
|
2022-09-24 17:47:21 +00:00
|
|
|
subbrute_free(instance);
|
2022-09-25 21:07:16 +00:00
|
|
|
|
2022-09-07 13:38:20 +00:00
|
|
|
return 0;
|
|
|
|
}
|