wifi_deauther_scene_text_input.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #include "../wifi_deauther_app_i.h"
  2. void wifi_deauther_scene_text_input_callback(void* context) {
  3. WifideautherApp* app = context;
  4. view_dispatcher_send_custom_event(app->view_dispatcher, WifideautherEventStartConsole);
  5. }
  6. void wifi_deauther_scene_text_input_on_enter(void* context) {
  7. WifideautherApp* app = context;
  8. if(false == app->is_custom_tx_string) {
  9. // Fill text input with selected string so that user can add to it
  10. size_t length = strlen(app->selected_tx_string);
  11. furi_assert(length < WIFI_deauther_TEXT_INPUT_STORE_SIZE);
  12. bzero(app->text_input_store, WIFI_deauther_TEXT_INPUT_STORE_SIZE);
  13. strncpy(app->text_input_store, app->selected_tx_string, length);
  14. // Add space - because flipper keyboard currently doesn't have a space
  15. app->text_input_store[length] = ' ';
  16. app->text_input_store[length + 1] = '\0';
  17. app->is_custom_tx_string = true;
  18. }
  19. // Setup view
  20. TextInput* text_input = app->text_input;
  21. // Add help message to header
  22. if(0 == strncmp("ssid -a -g", app->selected_tx_string, strlen("ssid -a -g"))) {
  23. text_input_set_header_text(text_input, "Enter # SSIDs to generate");
  24. } else if(0 == strncmp("ssid -a -n", app->selected_tx_string, strlen("ssid -a -n"))) {
  25. text_input_set_header_text(text_input, "Enter SSID name to add");
  26. } else if(0 == strncmp("ssid -r", app->selected_tx_string, strlen("ssid -r"))) {
  27. text_input_set_header_text(text_input, "Remove target from SSID list");
  28. } else if(0 == strncmp("select -a", app->selected_tx_string, strlen("select -a"))) {
  29. text_input_set_header_text(text_input, "Add target from AP list");
  30. } else if(0 == strncmp("select -s", app->selected_tx_string, strlen("select -s"))) {
  31. text_input_set_header_text(text_input, "Add target from SSID list");
  32. } else {
  33. text_input_set_header_text(text_input, "Add command arguments");
  34. }
  35. text_input_set_result_callback(
  36. text_input,
  37. wifi_deauther_scene_text_input_callback,
  38. app,
  39. app->text_input_store,
  40. WIFI_deauther_TEXT_INPUT_STORE_SIZE,
  41. false);
  42. view_dispatcher_switch_to_view(app->view_dispatcher, WifideautherAppViewTextInput);
  43. }
  44. bool wifi_deauther_scene_text_input_on_event(void* context, SceneManagerEvent event) {
  45. WifideautherApp* app = context;
  46. bool consumed = false;
  47. if(event.type == SceneManagerEventTypeCustom) {
  48. if(event.event == WifideautherEventStartConsole) {
  49. // Point to custom string to send
  50. app->selected_tx_string = app->text_input_store;
  51. scene_manager_next_scene(app->scene_manager, WifideautherAppViewConsoleOutput);
  52. consumed = true;
  53. }
  54. }
  55. return consumed;
  56. }
  57. void wifi_deauther_scene_text_input_on_exit(void* context) {
  58. WifideautherApp* app = context;
  59. text_input_reset(app->text_input);
  60. }